Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@crawly/handler-exception-lambda

Package Overview
Dependencies
Maintainers
6
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crawly/handler-exception-lambda - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0

dist/errors/internalServerError.js

47

dist/index.js

@@ -16,5 +16,9 @@ "use strict";

exports.Raven = Raven;
var notFoundError_1 = require("./errors/notFoundError");
exports.NotFoundError = notFoundError_1.NotFoundError;
var internalServerError_1 = require("./errors/internalServerError");
exports.InternalServerError = internalServerError_1.InternalServerError;
Raven.config(process.env.SENTRY_DSN, {
shouldSendCallback: function (data) {
return !exports.isOffline();
return !isOffline();
},

@@ -25,3 +29,4 @@ }).install();

*/
exports.isOffline = function () { return process.env.IS_OFFLINE === 'true'; };
var isOffline = function () { return process.env.IS_OFFLINE === 'true'; };
exports.isOffline = isOffline;
/**

@@ -35,4 +40,4 @@ * Track the exception on sentry.

*/
exports.track = function (event, context, error, options) {
if (error.ignoreOnTrack || exports.isOffline()) {
var track = function (event, context, error, options) {
if (error.ignoreOnTrack || isOffline()) {
return;

@@ -55,2 +60,3 @@ }

};
exports.track = track;
/**

@@ -61,3 +67,3 @@ * Get the response when error occurs.

*/
exports.getErrorResponse = function (error) {
var getErrorResponse = function (error) {
var messages = error.messages && Array.isArray(error.messages)

@@ -81,3 +87,3 @@ ? error.messages

};
if (exports.isOffline()) {
if (isOffline()) {
response.stackTrace = error.stack;

@@ -87,1 +93,30 @@ }

};
exports.getErrorResponse = getErrorResponse;
/**
* Build a standard error response and call the track on sentry
*
* @param error
* @param trackError
* @param responseHeaders
* @param overrideMsgByStatusCodeMap
*
*/
var buildStandardErrorResponse = function (error, trackError, responseHeaders, overrideMsgByStatusCodeMap) {
if (responseHeaders === void 0) { responseHeaders = null; }
var rh = responseHeaders ? responseHeaders :
{ 'content-type': 'application/json; charset=utf-8' };
if (trackError) {
track(trackError.event, trackError.context, error, trackError.options);
}
var errorResponse = getErrorResponse(error);
var sc = errorResponse.statusCode;
if (overrideMsgByStatusCodeMap && overrideMsgByStatusCodeMap.has(sc)) {
errorResponse.messages = [overrideMsgByStatusCodeMap.get(sc)];
}
return {
statusCode: sc,
headers: rh,
body: JSON.stringify(errorResponse),
};
};
exports.buildStandardErrorResponse = buildStandardErrorResponse;

2

package.json
{
"name": "@crawly/handler-exception-lambda",
"version": "0.2.3",
"version": "0.3.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

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