Skip to content

Application specific error codes #819

Description

@mattias-p

The JSONRPC specification allows applications to specify their own error codes. Today all handler methods in the RPCAPI module catch exceptions at their top level and generate errors with the generic code -32603 (Internal error).

We should:

  • Pick a small set of error states that we want to generate application defined error responses for.
  • Update the "Error reporting" section in the API document to include those error states.

For each error state we should also:

  1. Create a class method named after its message string in lower snake case. This method should return a data structure that represents an JSONRPC error object for this error state. If the error state has a described data type, the method should take appropriate arguments so the data member of the error object can be properly populated.
  2. Make sure this error state throws an exception that can be recognized in a reliable way.
  3. Determine all handler methods where this exception can end up.
  4. Update exactly those handler methods to recognize the exception. When such an exception is recognized, the class method should be used to create an error object so the application defined error response can be returned instead of the generic -32603 response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions