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/grpc-js')
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)
console.log(err.message)
console.log(err.code)
console.log(err.metadata instanceof grpc.Metadata)
console.log(err.metadata.getMap())
const GRPCError = require('grpc-error')
const error = new GRPCError('Boom', { status_code: 'INVALID_TOKEN' )
console.log(err instanceof Error)
console.log(err.message)
console.log(err.metadata instanceof grpc.Metadata)
console.log(err.metadata.getMap())
License
Apache-2.0