interledger-deprecated / java-ilp-core

WE'VE MOVED: This project has moved to Hyperledger Quilt
https://github.com/hyperledger/quilt/tree/master/ilp-core
Apache License 2.0
16 stars 10 forks source link

Differentiate between RuntimeExceptions and protocol exceptions #59

Closed adrianhopebailie closed 7 years ago

adrianhopebailie commented 7 years ago

We should extend RuntimeException so that users of the library can differentiate between exceptions from our lib and others.

That said, we can't use InterledgerException as it is, because this is designed to be thrown in the case of an InterledgerError (i.e. a protocol exception).

Suggest we rename InterledgerException to InterledgerProtocolException and add a sub-class of RuntimeException called InterledgerCoreRuntimeException that is used within the library and is package private.

sappenin commented 7 years ago

+1 on the rename to InterledgerProtocolException.

However, can you clarify the value of InterledgerCoreRuntimeException? Just wondering why not use RuntimeException (I'm assuming that callers will need to know something deeper about the error, but am trying to reason through what exactly that is, if it's not a "Protocol" error).

adrianhopebailie commented 7 years ago

A number of static analysis tools I have run on the code suggest changing this. There are two good reasons I can think of:

  1. Control over the interface so we can accommodate future changes
  2. Logging. If an operator sees an InterledgerRuntimeException they can immediately see that it was generated by the ILP code.
sappenin commented 7 years ago

Makes sense. What if we just called it InterledgerRuntimeException instead? Then we would have the following structure:

(I kind-of agree with the above suggestion, but am open to an argument in-favor of keeping the two exceptions distinct).

adrianhopebailie commented 7 years ago

Implemented like you suggest. See PR #58