Skip to content

Commit

Permalink
Correct example of exception override
Browse files Browse the repository at this point in the history
  • Loading branch information
KLarpen committed Dec 22, 2023
1 parent dcbc596 commit f6fa0a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions content/en/LAYERS.md
Original file line number Diff line number Diff line change
@@ -160,10 +160,10 @@ Example with raise exception:

Result with exception (metacom packet): `{"callback":1,"error":{"message":"Internal Server Error","code":500}}`

How to override error codes: `throw new Error('Method is not implemented', 404);`
This will take error message from code: `{"callback":1,"error":{"message":"Not found","code":404}}`
How to override error codes: `throw new Error('Not found', 404);`
This will take error message and code as is: `{"callback":1,"error":{"message":"Not found","code":404}}`

If you specify unknown code like this: `throw new Error('Method is not implemented', 12345);` this will generate: `"Internal Server Error"` with `"code":500`.
If you specify unknown code like this `throw new Error('Method is not implemented', 12345);`, this will generate: `"Internal Server Error"` with `"code":500`.

## Network

0 comments on commit f6fa0a7

Please sign in to comment.