From 0424f092637bca4924d2a8855cf367247e4bf364 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Wed, 5 Oct 2022 22:40:18 +0300 Subject: [PATCH] Added section about errors handling to docs --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d15d661..aba3e8a 100644 --- a/README.md +++ b/README.md @@ -1017,16 +1017,19 @@ stored in `opStatus.error`. This allows, for example, convenient handling of dif types of errors: ```javascript +import {Wampy, Errors} from 'wampy'; +const wampy = new Wampy('/ws/', { realm: 'AppRealm' }); + try { - await ws.call('start.migration'); + await wampy.call('start.migration'); console.log('RPC successfully called'); } catch (e) { console.log('Error happened!'); - if (e instanceof UriError) { + if (e instanceof Errors.UriError) { // statements to handle UriError exceptions - } else if (e instanceof InvalidParamError) { + } else if (e instanceof Errors.InvalidParamError) { // statements to handle InvalidParamError exceptions - } else if (e instanceof NoSerializerAvailableError) { + } else if (e instanceof Errors.NoSerializerAvailableError) { // statements to handle NoSerializerAvailableError exceptions } else { // statements to handle any unspecified exceptions