Registry / devops / grpc-error-extra

grpc-error-extra

JSON →
library1.1.1jsnpmunverified

Utility error class for gRPC error responses that can carry custom details. Version 1.1.1 is the latest stable release. The package is actively maintained and designed to work with @grpc/grpc-js. It differs from similar libraries by allowing arbitrary metadata and nesting of error details, making it suitable for rich error reporting in gRPC services.

npm install grpc-error-extra
INSTALL
IMPORT
SIG · GRPC-ERROR-EXTRA
G
grpc-error-extra
devopsjavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GrpcError
import { GrpcError } from 'grpc-error-extra'
const GrpcError = require('grpc-error-extra')
ESM import is preferred; CJS require works as well but may cause TypeScript issues if types are not resolved.

Shows how to create a GrpcError with custom details and access its properties.

import { status } from '@grpc/grpc-js'; import { GrpcError } from 'grpc-error-extra'; // Example with custom details const error = new GrpcError('Validation failed', { statusCode: status.INVALID_ARGUMENT, details: [{ field: 'name', description: 'Name must be unique' }] }); console.log(error.message); // 'Validation failed' console.log(error.details); // [{ field: 'name', description: 'Name must be unique' }] console.log(error.code); // 3 (INVALID_ARGUMENT)
Debug
Known issues
gotchaGrpcError expects the second argument to be an object with optional statusCode, details, and innerError properties. Passing plain strings or numbers may result in unexpected behavior.
fix
Always pass an object as the second argument. Use { statusCode: ... } for gRPC status codes.
affects: >=1.0.0
deprecatedThe package's peer dependency @grpc/grpc-js version range is >=1.2.0; newer versions of @grpc/grpc-js may have breaking changes.
fix
Ensure your @grpc/grpc-js version is compatible; if upgrading, test error handling.
affects: >=1.1.0
gotchaGrpcError constructor does not validate the status code; invalid numeric codes may cause issues downstream.
fix
Use the status enum from @grpc/grpc-js to ensure valid codes.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Class extends value undefined is not a constructor or null
Missing or incorrect @grpc/grpc-js peer dependency
fix
Run: npm install @grpc/grpc-js
export 'GrpcError' was not found in 'grpc-error-extra'
Using wrong import syntax or older version without TypeScript types
fix
Use correct import: import { GrpcError } from 'grpc-error-extra'
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredPeer dependency required for status codes and gRPC integration
Agent activity
8 hits · last 30 days
node
8
Resources
grpc-error-extra — npm install grpc-error-extra · libregistry