Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom errors overwritten #338

Closed
StrathCole opened this issue Sep 29, 2024 · 1 comment · Fixed by #342
Closed

Custom errors overwritten #338

StrathCole opened this issue Sep 29, 2024 · 1 comment · Fixed by #342

Comments

@StrathCole
Copy link

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants