Skip to content

Commit

Permalink
Added section about errors handling to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Oct 5, 2022
1 parent 10e202b commit 0424f09
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0424f09

Please sign in to comment.