libplanet icon indicating copy to clipboard operation
libplanet copied to clipboard

Use composition instead of inheritance for `SwarmException`s

Open greymistcube opened this issue 3 years ago • 1 comments

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 SwarmException has 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.

greymistcube avatar Apr 26 '22 08:04 greymistcube

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

stale[bot] avatar Jul 31 '22 01:07 stale[bot]