Skip to content

Standardize best practices for error handling in libraries #3423

@mDuo13

Description

@mDuo13

Our sample code should embody best practices around catching errors, even if all the sample code does after catching the error is just to print it and quit.

This can be tricky because the client libraries handle different types of errors differently:

  • They throw an exception for some types of errors, like a network error or syntax/request formatting error.
  • They return an unsuccessful response from the server, without throwing, for other types of errors like an entry or transaction not found in the ledger/history.
  • They return a transaction that was validated with a tec code, meaning it probably did not accomplish its intended purpose, without throwing.

Also, I'm not sure that xrpl.js and xrpl-py are even consistent with each other in how they handle these cases, to say nothing of other client libraries.

Acceptance Criteria

Create a new document or section describes the best practices for handling, in both Python and JavaScript, the following error cases:

  • API request failures in processing (like network errors).
  • API responses that include an error from the server (like "not found" errors).
  • Transaction results that aren't successful, when submitting transactions using a "submit and wait" function.
  • Bonus points: using a "simple" transaction submit function that does not wait for a validated result. (For example, a response of terQUEUED indicates the transaction will likely become validated soon but is not a final result.

If possible: update sample code of relevant tutorials to embody the best practices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    javascriptPull requests that update Javascript codenew topicDescribes a detailed document to be added or expanded in detailorganizationInformation architecture, restructuring, interlinking, etc.pythonPull requests that update Python code

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions