vacp2p / nim-libp2p

libp2p implementation in Nim
https://vacp2p.github.io/nim-libp2p/docs/
MIT License
249 stars 54 forks source link

define proper parent error type for `YamuxError` #1040

Closed etan-status closed 7 months ago

etan-status commented 7 months ago

All errors raised by nim-libp2p should descend from LPError. YamuxError was not correctly classified. Proposing it to be a specialized MuxerError, in line with mplex and muxer errors.

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.77%. Comparing base (6c87348) to head (29d9c1d).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/status-im/nim-libp2p/pull/1040/graphs/tree.svg?width=650&height=150&src=pr&token=UR5JRQ249W&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=status-im)](https://app.codecov.io/gh/status-im/nim-libp2p/pull/1040?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=status-im) ```diff @@ Coverage Diff @@ ## unstable #1040 +/- ## ========================================= Coverage 82.77% 82.77% ========================================= Files 91 91 Lines 15604 15604 ========================================= Hits 12916 12916 Misses 2688 2688 ``` | [Files](https://app.codecov.io/gh/status-im/nim-libp2p/pull/1040?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=status-im) | Coverage Δ | | |---|---|---| | [libp2p/muxers/yamux/yamux.nim](https://app.codecov.io/gh/status-im/nim-libp2p/pull/1040?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=status-im#diff-bGlicDJwL211eGVycy95YW11eC95YW11eC5uaW0=) | `88.34% <ø> (ø)` | |
diegomrsantos commented 6 months ago

@etan-status Could you please explain what LPError means and why errors should descend from it?

dryajov commented 6 months ago

@etan-status Could you please explain what LPError means and why errors should descend from it?

LPError is the root object of libp2p's error hierarchy - this has always been it's original intent.

diegomrsantos commented 6 months ago

Thanks, I meant literally, what does the name mean?

dryajov commented 6 months ago

Thanks, I meant literally, what does the name mean?

Oh, heh - the LP prefix was chosen as a shorthand for libp2p, otherwise we'd be writing something like Libp2pError all over the place :)

diegomrsantos commented 6 months ago

I see, maybe P2PError would be more descriptive?

dryajov commented 6 months ago

I see, maybe P2PError would be more descriptive?

well, imo p2p is quite generic and LP is a well established convention in nim libp2p, I personally don't see a need to change it, but I'm also don't feel very strongly about it.

diegomrsantos commented 6 months ago

It never crossed my mind that LP means libp2p. I believe a comment or docs would be beneficial.

etan-status commented 6 months ago

@etan-status Could you please explain what LPError means and why errors should descend from it?

It's a followup from #582. LPError is the root of all nim-libp2p originated errors. That convention is mostly followed, with very few individual exceptions that are being addressed. Rationale is so that {.async: (raises).} can be restricted to the parent for the outermost layer.