iso-error-google-cloud-api
v6.0.6
Published
iso-error plugin for Google Cloud API design
Downloads
211
Readme
iso-error-google-cloud-api
iso-error
plugin for Google Cloud API design.
Since iso-error
is about sending data across physical boundary,
the DebugInfo
is removed for security purpose.
Install
yarn add iso-error-google-cloud-api
Usage
// server
import { IsoError } from 'iso-error'
import { googleCloudApiPlugin } from 'iso-error-google-cloud-api'
IsoError.addPlugin(googleCloudApiPlugin)
try {
doSomeWorkThatThrows()
}
catch (e) {
const ge = convertToGoogleError(e)
response.emit(IsoError.serialize(ge))
}
// client
import { IsoError } from 'iso-error'
import { googleCloudApiPlugin } from 'iso-error-google-cloud-api'
IsoError.addPlugin(googleCloudApiPlugin)
try {
fetch('<serverUrl>').then(response => {
if (!response.ok) {
throw IsoError.deserialize(response.text())
}
})
}