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

Suggestion: include relay url in error object #4

Open
antonioconselheiro opened this issue Oct 17, 2024 · 2 comments
Open

Suggestion: include relay url in error object #4

antonioconselheiro opened this issue Oct 17, 2024 · 2 comments

Comments

@antonioconselheiro
Copy link

Gm,
I would like to suggest to include an attribute in errors thrown in relay, the relay address info.

export class NetworkError extends Error {
  constructor(
    msg: string,
    public relay: WebSocket['url']
  ) {
    super(msg);
  }
}

So you can throw like this:

if (!ok) {
  throw new NetworkError(reason, this.url);
}

throw new Error(reason);

You think is make sense?

@alexgleason
Copy link
Member

Yes. i almost did it in the first place, but figured I would wait until somebody actually needed it. Mainly because I want to take care how I name this Error class, and where to put it.

@antonioconselheiro
Copy link
Author

Good.
Knowing the error origin can help users review relay list, by removing relays with more number of errors.

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

No branches or pull requests

2 participants