forked from aws/aws-lambda-nodejs-runtime-interface-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErrorsTest.js
32 lines (26 loc) · 1.07 KB
/
ErrorsTest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*/
'use strict';
require('should');
let Errors = require('lambda-runtime/Errors');
describe('Formatted Error Logging', () => {
it('should fall back to a minimal error format when an exception occurs', () => {
let error = new Error('custom message');
error.name = 'CircularError';
error.backlink = error;
let loggedError = JSON.parse(Errors.toFormatted(error).trim());
loggedError.should.have.property('errorType', 'CircularError');
loggedError.should.have.property('errorMessage', 'custom message');
loggedError.should.have.property('trace').with.length(11);
});
});
describe('Invalid chars in HTTP header', () => {
it('should be replaced', () => {
let errorWithInvalidChar = new Error('\x7F \x7F');
errorWithInvalidChar.name = 'ErrorWithInvalidChar';
let loggedError = Errors.toRapidResponse(errorWithInvalidChar);
loggedError.should.have.property('errorType', 'ErrorWithInvalidChar');
loggedError.should.have.property('errorMessage', '%7F %7F');
});
});