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 c74f1011d0
commit 163079d278
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) { if (enrichedQuery.json || enrichedQuery.customData) {
enrichedQuery.json = JSON.parse( try {
enrichedQuery.json || enrichedQuery.customData enrichedQuery.json = JSON.parse(
) enrichedQuery.json || enrichedQuery.customData
)
} catch (err) {
throw { message: `JSON Invalid - error: ${err}` }
}
delete enrichedQuery.customData delete enrichedQuery.customData
} }