driplineorg / dripline-python

python implementation of project8/dripline
Apache License 2.0
3 stars 6 forks source link

Interface needs local and service exception support #124

Open laroque opened 4 years ago

laroque commented 4 years ago

The Interface class is useful in two very different contexts: as a member of a service which needs to communicate with other services, or as a local variable in an interpreter or script. In the former case, certain error conditions should a ThrowReply, so that we can send the client an error reply with reasonable return code, but the the later case, this will result in new exceptions because there is no request to reply to.

The suggested solution is to implement a custom exception with the same interface/signature as ThrowReply, but which is just a local exception. When the interface is initialized, it should include a kwarg for indicating the execution context (default for local use) which assigns a local reference to either ThrowReply or this new exception, that reference should be used throughout.