@crawly/handler-exception-lambda
Advanced tools
Comparing version 0.2.3 to 0.3.0
@@ -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; |
{ | ||
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7798
4
201
0