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

Commit c177c2a

Browse files
author
tkostuch
committed
update error handling
1 parent f3082d1 commit c177c2a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/api/catalog.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ export default ({config, db}) => async function (req, res, body) {
5151
let requestBody = req.body
5252
if (req.method === 'GET') {
5353
if (req.query.request) { // this is in fact optional
54-
requestBody = JSON.parse(decodeURIComponent(req.query.request))
54+
try {
55+
requestBody = JSON.parse(decodeURIComponent(req.query.request))
56+
} catch (err) {
57+
throw new Error(err)
58+
}
5559
}
5660
}
5761

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ app.use('/graphql', graphqlExpress(req => ({
7272
app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
7373

7474
app.use((err, req, res, next) => {
75-
const { statusCode, message = '', stack = '' } = err;
75+
const { statusCode = 500, message = '', stack = '' } = err;
7676
const stackTrace = stack
7777
.split(/\r?\n/)
7878
.map(string => string.trim())

0 commit comments

Comments
 (0)