mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
fix(errors): Show a better error when the sent JSON body as a syntax error (#1683)
Fixes HDX-3319
This commit is contained in:
parent
2f1a13cc81
commit
4e7d04c7b0
2 changed files with 8 additions and 1 deletions
5
.changeset/friendly-panthers-reply.md
Normal file
5
.changeset/friendly-panthers-reply.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"@hyperdx/api": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
API: Show error "Invalid JSON payload" if the JSON body has a syntax error
|
||||||
|
|
@ -15,7 +15,9 @@ export const appErrorHandler = (
|
||||||
|
|
||||||
const userFacingErrorMessage = isOperationalError(err)
|
const userFacingErrorMessage = isOperationalError(err)
|
||||||
? err.name || err.message
|
? err.name || err.message
|
||||||
: 'Something went wrong :(';
|
: err instanceof SyntaxError && err.message.includes('JSON')
|
||||||
|
? 'Invalid JSON payload'
|
||||||
|
: 'Something went wrong :(';
|
||||||
|
|
||||||
void recordException(err, {
|
void recordException(err, {
|
||||||
mechanism: {
|
mechanism: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue