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

p2p: more ergonomic errors #167

Open
bajtos opened this issue Mar 30, 2023 · 0 comments
Open

p2p: more ergonomic errors #167

bajtos opened this issue Mar 30, 2023 · 0 comments
Assignees
Labels
feature New feature or request libp2p All things related to libp2p

Comments

@bajtos
Copy link
Member

bajtos commented Mar 30, 2023

At the moment, errors reported by libp2p are translated to vanilla JavaScript errors with no additional properties. This makes it difficult to implement custom handling for specific kinds of errors (e.g. timeouts).

Example error:

Identify protocol failed: Error: cannot dial remote peer: Timeout while waiting for a response
    at async Object.requestProtocol (ext:zinnia_libp2p/01_peer.js:14:27)
    at async probe (file:///Users/bajtos/src/zinnia/mod-peer-checker/peer-checker.js:29:22)
    at async file:///Users/bajtos/src/zinnia/mod-peer-checker/peer-checker.js:104:33

I am proposing to improve the layer converting rust-libp2p errors into JavaScript errors to produce machine-readable error objects.

For example:

  • Change the error name to something like PeerError
  • Add a code property set to a unique string that can be used to differentiate errors. For example map OutboundFailure::Timeout to { code: "OUTBOUND_TIMEOUT" }
@bajtos bajtos added feature New feature or request libp2p All things related to libp2p labels Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request libp2p All things related to libp2p
Projects
None yet
Development

No branches or pull requests

1 participant