Skip to content

Handling errors from rippled requests

Elliot Lee edited this page Apr 8, 2020 · 1 revision

When using api.request, a successful response from rippled is passed to your then function.

A failure (error) from rippled is passed to your catch function. Here is an example for request('account_info', ...) when the account does not exist:

[RippledError(Account not found., { account: 'rQ3fNyLjbvcDaPNS4EAJY8aT9zR3uGk17c',
  error: 'actNotFound',
  error_code: 19,
  error_message: 'Account not found.',
  id: 1,
  ledger_current_index: 6468974,
  request:
    { account: 'rQ3fNyLjbvcDaPNS4EAJY8aT9zR3uGk17c',
      command: 'account_info',
      id: 1,
      ledger_index: 'current' },
      status: 'error',
      type: 'response',
      validated: false })]

The type of the Error object is RippledError. The top-level object is accessible via error.data (for example, to access 'actNotFound', use error.data.error). In this case, Account not found. is the message, accessible via error.message.