Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit 817d5ec

Browse files
author
tkostuch
committed
move stack from result message
1 parent 7a2e7ad commit 817d5ec

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,15 @@ app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
7373

7474
app.use((err, req, res, next) => {
7575
const { statusCode, message, stack } = err;
76+
const stackTrace = stack
77+
.split(/\r?\n/)
78+
.map(string => string.trim())
79+
.filter(string => string !== '')
80+
7681
res.status(statusCode).json({
7782
code: statusCode,
78-
result: config.get('server.showErrorStack') ? `
79-
message: ${message};
80-
stack: ${stack}
81-
` : message
83+
result: message,
84+
...(config.get('server.showErrorStack') ? { stack: stackTrace } : {})
8285
});
8386
});
8487

0 commit comments

Comments
 (0)