From f6fa0a781a18b63a01f1ed0c8bb9c74ee3c491af Mon Sep 17 00:00:00 2001 From: Vladyslav Karpenko Date: Fri, 22 Dec 2023 13:16:13 +0200 Subject: [PATCH] Correct example of exception override Closes: https://github.com/metarhia/Docs/issues/21 Refs: https://github.com/metarhia/metacom/pull/486 --- content/en/LAYERS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/en/LAYERS.md b/content/en/LAYERS.md index 98bce7e..b8382cd 100644 --- a/content/en/LAYERS.md +++ b/content/en/LAYERS.md @@ -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