New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grpc-web-error-details

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-web-error-details - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

5

dist/src/grpc-web-error-details.d.ts
import { Status } from "../lib/status_pb";
import * as ErrorDetailsPb from "../lib/error_details_pb";
export declare type ErrorDetails = ErrorDetailsPb.RetryInfo | ErrorDetailsPb.DebugInfo | ErrorDetailsPb.QuotaFailure | ErrorDetailsPb.ErrorInfo | ErrorDetailsPb.PreconditionFailure | ErrorDetailsPb.BadRequest | ErrorDetailsPb.RequestInfo | ErrorDetailsPb.ResourceInfo | ErrorDetailsPb.Help | ErrorDetailsPb.LocalizedMessage;
export declare function statusFromError(err: object | {
export declare function statusFromError(err: any | {
metadata: {
"grpc-status-details-bin"?: string;
};
} | {
code?: number;
message?: string;
}): [Status, ErrorDetails[]] | [null, null];
//# sourceMappingURL=grpc-web-error-details.d.ts.map

17

dist/src/grpc-web-error-details.js

@@ -48,8 +48,19 @@ "use strict";

}
function statusFromError(err) {
// to get status, we requires err['metadata']['grpc-status-details-bin']
function statusFromError(err // error with status code and status message
) {
// to parse status details, we requires err['metadata']['grpc-status-details-bin']
if (!("metadata" in err &&
"grpc-status-details-bin" in err["metadata"] &&
typeof err.metadata["grpc-status-details-bin"] === "string")) {
// if the error does not contain status, return null
// if the error does not contain details bin, check if err contains status only
if (("code" in err && typeof err.code === "number") ||
("message" in err && typeof err.message === "string")) {
// if so, return the status and an empty array for details
const st = new status_pb_1.Status();
st.setCode(err.code);
st.setMessage(err.message);
st.setDetailsList([]);
return [st, []];
}
// if the error does not have any information, return null
return [null, null];

@@ -56,0 +67,0 @@ }

{
"name": "grpc-web-error-details",
"version": "1.0.1",
"version": "1.1.0",
"description": "Utility function for deserializing `grpc-status-details-bin` metadata on grpc-web",

@@ -35,3 +35,3 @@ "license": "MIT",

"genProto": "bash ./run-protoc.sh",
"prepublish": "build"
"prepare": "npm run build"
},

@@ -38,0 +38,0 @@ "dependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc