mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-04-29 15:37:50 +00:00
40 lines
1.0 KiB
Plaintext
40 lines
1.0 KiB
Plaintext
# API Events
|
|
|
|
## ledger
|
|
|
|
This event is emitted whenever a new ledger version is validated on the connected server.
|
|
|
|
### Return Value
|
|
|
|
<%- renderSchema('output/ledger-event.json') %>
|
|
|
|
### Example
|
|
|
|
```javascript
|
|
api.on('ledger', ledger => {
|
|
console.log(JSON.stringify(ledger, null, 2));
|
|
});
|
|
```
|
|
|
|
<%- renderFixture('responses/ledger-event.json') %>
|
|
|
|
## error
|
|
|
|
This event is emitted when there is an error on the connection to the server that cannot be associated to a specific request.
|
|
|
|
### Return Value
|
|
|
|
The first parameter is a string indicating the error type, which may be `badMessage` (meaning that rippled returned a malformed message), or one of the [rippled Universal Errors](https://ripple.com/build/rippled-apis/#universal-errors). The second parameter is a message explaining the error, or the message that caused the error in the case of `badMessage`.
|
|
|
|
### Example
|
|
|
|
```javascript
|
|
api.on('error', (errorCode, errorMessage) => {
|
|
console.log(errorCode + ': ' + errorMessage);
|
|
});
|
|
```
|
|
|
|
```
|
|
tooBusy: The server is too busy to help you now.
|
|
```
|