@crawly/handler-exception-lambda
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -53,3 +53,5 @@ "use strict"; | ||
exports.getErrorResponse = function (error) { | ||
var messages = [error.message]; | ||
var messages = error.messages && Array.isArray(error.messages) | ||
? error.messages | ||
: [error.message]; | ||
var statusCode = error.statusCode ? error.statusCode : 500; | ||
@@ -56,0 +58,0 @@ var timeoutCauses = ['ECONNRESET', 'ESOCKETTIMEDOUT']; |
{ | ||
"name": "@crawly/handler-exception-lambda", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -68,3 +68,6 @@ import * as Raven from 'raven'; | ||
export const getErrorResponse = (error: any): ErrorResponse => { | ||
const messages = [error.message]; | ||
const messages = error.messages && Array.isArray(error.messages) | ||
? error.messages | ||
: [error.message]; | ||
let statusCode = error.statusCode ? error.statusCode : 500; | ||
@@ -71,0 +74,0 @@ |
@@ -343,2 +343,12 @@ import { expect } from 'chai'; | ||
}); | ||
it('Use messages if exists to generate messages', () => { | ||
const errorsMessages = Array(5).fill('').map(() => faker.lorem.words()); | ||
const error = new ErrorWithMessages(errorsMessages); | ||
const errorResponse = getErrorResponse(error); | ||
expect(errorResponse).to.have.property('messages') | ||
.and.to.be.deep.equal(errorsMessages); | ||
}); | ||
}); | ||
@@ -370,1 +380,11 @@ }); | ||
} | ||
class ErrorWithMessages extends Error { | ||
public messages: string[]; | ||
constructor(messages: string[], message?: string) { | ||
super(message); | ||
this.messages = messages; | ||
} | ||
} |
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
18894
502