Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reword the message printed by REST LogError action #6556

Merged
merged 1 commit into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,17 @@ describe('RestServer (integration)', () => {
console.error = consoleError;
});

it('responds with 500 when Sequence fails with unhandled error', async () => {
it('responds with 500 when Sequence returns a rejected promise', async () => {
server.handler((context, sequence) => {
return Promise.reject(new Error('unhandled test error'));
});
await createClientForHandler(server.requestHandler).get('/').expect(500);
expect(errorMsg).to.match(
/Unhandled error in GET \/\: 500 Error\: unhandled test error/,
/Request GET \/\ failed with status code 500. Error\: unhandled test error/,
);
});

it('hangs up socket when Sequence fails with unhandled error and headers sent', async () => {
it('hangs up socket when Sequence returns a rejected promise but headers were already sent', async () => {
server.handler((context, sequence) => {
context.response.writeHead(200);
return Promise.reject(new Error('unhandled test error after sent'));
Expand All @@ -198,7 +198,7 @@ describe('RestServer (integration)', () => {
createClientForHandler(server.requestHandler).get('/'),
).to.be.rejectedWith(/socket hang up/);
expect(errorMsg).to.match(
/Unhandled error in GET \/\: 500 Error\: unhandled test error after sent/,
/Request GET \/\ failed with status code 500. Error\: unhandled test error/,
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/rest/src/providers/log-error.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class LogErrorProvider implements Provider<LogError> {
}

console.error(
'Unhandled error in %s %s: %s %s',
'Request %s %s failed with status code %s. %s',
req.method,
req.url,
statusCode,
Expand Down