Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
feat(error): add response.errorStack for additional information. (#375)
Browse files Browse the repository at this point in the history
fixes #374
  • Loading branch information
tripodsan authored and stefan-guggisberg committed Jun 12, 2019
1 parent eac3fce commit e7a264b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils/openwhisk.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ async function createActionResponse(context) {
if (error) {
// don't set the 'error' property, otherwise openwhisk treats this as application error
ret.errorMessage = String(error);
if (error.stack) {
ret.errorStack = String(error.stack);
}
}
return ret;
}
Expand Down
2 changes: 2 additions & 0 deletions test/testHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ ${context.content.document.body.innerHTML}`,
path: 'not-existent.md',
});

assert.ok(out.errorStack.startsWith('StatusCodeError: 404'));
delete out.errorStack;
assert.deepEqual(out, {
body: '',
errorMessage: 'StatusCodeError: 404 - "404: Not Found\\n"',
Expand Down
6 changes: 6 additions & 0 deletions test/testOpenwhisk.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ describe('Testing OpenWhisk adapter', () => {
error: new Error('boom!'),
};
const out = await createActionResponse(inp);
assert.ok(out.errorStack.startsWith('Error: boom!'));
delete out.errorStack;
assert.deepEqual(out, {
body: {},
errorMessage: 'Error: boom!',
Expand All @@ -103,6 +105,8 @@ describe('Testing OpenWhisk adapter', () => {
error: new Error('Forbidden'),
};
const out = await createActionResponse(inp);
assert.ok(out.errorStack.startsWith('Error: Forbidden'));
delete out.errorStack;
assert.deepEqual(out, {
body: 'Forbidden',
errorMessage: 'Error: Forbidden',
Expand All @@ -121,6 +125,8 @@ describe('Testing OpenWhisk adapter', () => {
foo.bar = 'boom!';
}, pipe, {});

assert.ok(out.errorStack.startsWith('ReferenceError: foo is not defined'));
delete out.errorStack;
assert.deepEqual(out, {
body: {},
errorMessage: 'ReferenceError: foo is not defined',
Expand Down

0 comments on commit e7a264b

Please sign in to comment.