Adding a nicer error for when user input JSON is invalid.

This commit is contained in:
mike12345567 2021-02-02 16:44:31 +00:00
parent 6a41875556
commit febf06d3f6
1 changed files with 7 additions and 3 deletions

View File

@ -48,9 +48,13 @@ async function enrichQueryFields(fields, parameters) {
}
if (enrichedQuery.json || enrichedQuery.customData) {
enrichedQuery.json = JSON.parse(
enrichedQuery.json || enrichedQuery.customData
)
try {
enrichedQuery.json = JSON.parse(
enrichedQuery.json || enrichedQuery.customData
)
} catch (err) {
throw { message: `JSON Invalid - error: ${err}` }
}
delete enrichedQuery.customData
}