Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Custom errors overwritten #338

@StrathCole

Description

@StrathCole

The code in the fetch middleware forcefully overwrites any received error with a meaningless "internal JSON-RPC error".
Is there a valid reason to do that? If the JSON-RPC returns a valid error object with a correct code, message (and eventually data), why is that not used?

function parseResponse(fetchRes: Response, body: Record<string, Block>): Block {
  // check for error code
  if (fetchRes.status !== 200) {
    throw rpcErrors.internal({
      message: `Non-200 status code: '${fetchRes.status}'`,
      data: body,
    });
  }

  // check for rpc error
  if (body.error) {
    throw rpcErrors.internal({
      data: body.error,
    });
  }
  // return successful result
  return body.result;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions