libplanet
libplanet copied to clipboard
Use composition instead of inheritance for `SwarmException`s
https://github.com/planetarium/NineChronicles/blob/b9960475d1168adb0a31af3732a4e5d671c457b1/nekoyume/Assets/_Scripts/BlockChain/Agent.cs#L667-L689
Just my two cents, but I think wrapping inner exceptions at Swarm<T> layer thrown from another layer such as IProtocol is better than inheritance for two reasons:
- When logged, it isn't immediately apparent if
SwarmExceptionhas explicitly been caught if not handled carefully. - Inner layers in general do not need to know if thrown exceptions are of
SwarmException.
Also, if I'm not mistaken, seems like SwarmException is reserved for critical failures where continuation of normal Swarm<T> operations aren't really viable. If this is the case, this should be better documented.
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.