Socket
Socket
Sign inDemoInstall

grpc-error-extra

Package Overview
Dependencies
36
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    grpc-error-extra

Utility error class suitable for gRPC error responses and can carry custom details


Version published
Weekly downloads
8
increased by300%
Maintainers
1
Install size
124 kB
Created
Weekly downloads
 

Readme

Source

grpc-error-extra

npm version npm downloads

Utility error class suitable for gRPC error responses and can carry custom details

Install

npm i grpc-error-extra

Usage

Sending details to client

const { status } = require("@grpc/grpc-js");
const { GrpcError } = require("grpc-error-extra");

/*...*/

throw new GrpcError("Validation failed", {
  statusCode: status.INVALID_ARGUMENT,
  details: [
    {
      field: "name",
      description: "Name must be unique",
    },
  ],
});

Wrapping inner error

const { GrpcError } = require("grpc-error-extra");

/*...*/

try {
  /*...*/
} catch (error) {
  const grpcError = new GrpcError("Unhandled exception has occurred", { innerError: error });

  if (callback) callback(grpcError);
  else call.emit("error", grpcError);
}

Keywords

FAQs

Last updated on 13 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc