Skip to content

Commit 8a86e03

Browse files
committed
example of error handling
1 parent 536c717 commit 8a86e03

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

docs/index.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
path: getBoosters.md
2727
- name: getServerInfo
2828
path: getServerInfo.md
29+
- name: Error Handling
30+
path: errorHandling.md
2931
# - name: getSkyblockProfiles
3032
# path: getSkyblockProfiles.md
3133
# - name: getSkyblockMember

docs/methods/errorHandling.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Error Handling
2+
3+
Example of error handling in `getPlayer` method.
4+
5+
```js
6+
const { Errors } = require('hypixel-api-reborn');
7+
// invalid nickname
8+
hypixel.getPlayer('3424242').then((player) => {
9+
10+
}).catch((e) => {
11+
if (e.message === Errors.PLAYER_DOES_NOT_EXIST) {
12+
console.log(`Player doesn't exist!`);
13+
// here you can replace default error message with yours.
14+
}
15+
});
16+
```

0 commit comments

Comments
 (0)