iso-error-google-cloud-api
TypeScript icon, indicating that this package has built-in type declarations

6.0.6 • Public • Published

iso-error-google-cloud-api

NPM version NPM downloads Codecov

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())
    }
  })
}

/iso-error-google-cloud-api/

    Package Sidebar

    Install

    npm i iso-error-google-cloud-api

    Weekly Downloads

    6

    Version

    6.0.6

    License

    MIT

    Unpacked Size

    13.5 kB

    Total Files

    14

    Last publish

    Collaborators

    • unional