Skip to content
Utility Error class suitable for gRPC error responses
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
.npmignore
LICENSE Initial commit Dec 30, 2016
README.md Fixed syntax error in README file Feb 7, 2019
_config.yml
index.js
package-lock.json
package.json

README.md

grpc-error

Utility Error class suitable for gRPC error responses

Related

grpc-create-error - A helper function module that this class uses

grpc status codes - The grpc status codes.

Usage

const GRPCError = require('grpc-error')
const grpc = require('grpc')
const error = new GRPCError('Boom', grpc.status.INVALID_ARGUMENT)
const GRPCError = require('grpc-error')

const error = new GRPCError('Boom', 2000, { status_code: 'INVALID_TOKEN' )
console.log(err instanceof Error) // true
console.log(err.message) // 'Boom'
console.log(err.code) // 2000
console.log(err.metadata instanceof grpc.Metadata) // true
console.log(err.metadata.getMap()) // { status_code: 'INVALID_TOKEN' }
const GRPCError = require('grpc-error')

const error = new GRPCError('Boom', { status_code: 'INVALID_TOKEN' )
console.log(err instanceof Error) // true
console.log(err.message) // 'Boom'
console.log(err.metadata instanceof grpc.Metadata) // true
console.log(err.metadata.getMap()) // { status_code: 'INVALID_TOKEN' }

License

Apache-2.0

You can’t perform that action at this time.