Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@beforeyoubid/error-adapter
Advanced tools
A module to standardize error handling across the BYB platform
This is an error handling module that supports multiple error types and the handling of each type accordingly using Sentry.
The module does NOT set up a Sentry client, therefore a client must already be set up and initialized.
The module provides functions to handle the formatting of GraphQL errors and sending errors to Sentry based on the error type.
Error Type | Alert Raised in Sentry |
---|---|
Server Error | Yes |
Not Authorized | Yes |
Not Authenticated | No |
Not Found | No |
Validation Error | No |
Payment Error | No |
User Input Error | No |
Conflict Error | No |
yarn add @beforeyoubid/error-adapter
formatError
Using formatError
function to format errors in preparation for Sentry by passing formatError
function into GraphQL
handler.
import { ApolloServer } from 'apollo-server-lambda';
import withSentry from 'serverless-sentry-lib';
import schema from '../graphql';
import { formatError } from '@beforeyoubid/error-adapter';
const server = new ApolloServer({
schema,
formatError,
context: async ({ event, context }): Promise<ApplicationContext> => {
const headers = {};
let gqcontext = {};
if (event.headers) {
const sourceUserAgent =
_.get(event, 'headers.x-source-user-agent') || _.get(event, 'headers.X-Source-User-Agent');
gqcontext = {
sourceUserAgent,
};
}
return {
// cache,
functionName: context.functionName,
headers,
...gqcontext,
};
},
});
const graphqlHandler = server.createHandler({
cors: {
origin: '*',
methods: ['POST'],
},
});
export default withSentry(graphqlHandler);
handleErrorSentryOptions
Using handleErrorSentryOptions
function to send errors to Sentry by passing handleErrorSentryOptions
function into
lambda handler.
import { ApolloServer } from 'apollo-server-lambda';
import withSentry from 'serverless-sentry-lib';
import schema from '../graphql';
import { formatError, handleErrorSentryOptions } from '@beforeyoubid/error-adapter';
const server = new ApolloServer({
schema,
formatError,
context: async ({ event, context }): Promise<ApplicationContext> => {
const headers = {};
let gqcontext = {};
if (event.headers) {
const sourceUserAgent =
_.get(event, 'headers.x-source-user-agent') || _.get(event, 'headers.X-Source-User-Agent');
gqcontext = {
sourceUserAgent,
};
}
return {
// cache,
functionName: context.functionName,
headers,
...gqcontext,
};
},
});
const graphqlHandler = server.createHandler({
cors: {
origin: '*',
methods: ['POST'],
},
});
export default withSentry(handleErrorSentryOptions, graphqlHandler);
import withSentry from 'serverless-sentry-lib';
import { handleErrorSentryOptions, NotFound } from '@beforeyoubid/error-adapter';
export const cronHandler = withSentry(handleErrorSentryOptions, async (event, context) => {
console.log('EVENT: \n' + JSON.stringify(event, null, 2));
throw new Error('This error will be raised in Sentry');
throw new NotFound('This error will NOT be raised in Sentry');
return context.logStreamName;
});
FAQs
A module to standardize error handling across the BYB platform
The npm package @beforeyoubid/error-adapter receives a total of 268 weekly downloads. As such, @beforeyoubid/error-adapter popularity was classified as not popular.
We found that @beforeyoubid/error-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.