Registry / devops / grpc-exception

grpc-exception

JSON →
library1.0.2jsnpmunverified

Provides predefined gRPC exception classes for Node.js, mapping each gRPC status code (e.g., NotFound, InvalidArgument) to an error class with a corresponding `code` property. Version 1.0.2 is stable with no recent updates. This is a lightweight alternative to manually setting error codes, but minimal download popularity indicates niche or hobbyist use. Does not integrate with @grpc/grpc-js error handling.

npm install grpc-exception
INSTALL
IMPORT
SIG · GRPC-EXCEPTION
G
grpc-exception
devopsjavascriptv1.0.2
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.

Ok
import { Ok } from 'grpc-exception'
All exports are named.
Cancelled
import { Cancelled } from 'grpc-exception'
ESM only; CommonJS require works but TypeScript may complain.
NotFound
import { NotFound } from 'grpc-exception'
Predefined exception for gRPC status NOT_FOUND.

Shows how to throw and catch predefined gRPC exceptions, accessing code and message.

import { NotFound, InvalidArgument } from 'grpc-exception'; try { throw new NotFound('Resource not found'); } catch (err) { console.error(err.message); // 'Resource not found' console.error(err.code); // 5 } try { throw new InvalidArgument('Bad input'); } catch (err) { console.error(err.name); // 'InvalidArgument' console.error(err.code); // 3 }
Debug
Known issues
gotchaError names like 'Unknow' are misspelled; the corresponding gRPC code is 2 (UNKNOWN).
fix
Use the class as provided, but note the typo: 'Unknow' instead of 'Unknown'.
affects: <=1.0.2
deprecatedThe package has not been updated since 2018; may not work with modern @grpc/grpc-js.
fix
Consider using a more maintained library or manually constructing errors.
affects: all
gotchaThe package does not provide a base error class; each exception extends Error directly.
fix
Use instanceof checks on individual classes, not a common base.
affects: all
gotchaNo TypeScript type definitions shipped; consumers must declare types themselves.
fix
Create a .d.ts file or use @types/grpc-exception (nonexistent).
affects: all
Errors
Common errors & fixes
TypeError: Class extends value undefined is not a constructor or null
Circular dependency or incorrect import order in CommonJS environment.
fix
Use ESM imports (import) instead of require().
Cannot find module 'grpc-exception'
Package not installed or not found in node_modules.
fix
Run `npm install grpc-exception` and ensure Node.js version supports ESM if using import syntax.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
grpc-exception — npm install grpc-exception · libregistry