Skip to content

Commit 9fda11e

Browse files
authored
Added example on catching to readme
Added example on how to catch async errors to readme
1 parent a46e5cf commit 9fda11e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ Requests:
109109
*/
110110
setDieType(GoDice.diceTypes)
111111
```
112+
113+
``javascript
114+
/**
115+
* In order to catch error on the requestDevice and attemptReconnect methods use an async function and await the die's methods
116+
* Example:
117+
*/
118+
async function openConnectionDialog() {
119+
const newDice = new GoDice();
120+
try {
121+
await newDice.requestDevice();
122+
} catch {
123+
console.log("Error on connecting die")
124+
}
125+
}
112126

113127

114128
Responses:

0 commit comments

Comments
 (0)