Skip to content

Standardize exception handling #166

@nsoblath

Description

@nsoblath

Exception handling in dl-cpp: driplineorg/dripline-cpp#103

The primary execution of most actions in dl-py takes place in C++, so most error handling will end up in the C++ code. Between C++ and Python the typical sequence of stages is Caller (Python) --> Execution (C++) --> Details (Python). Details includes things like doing calibrations. Most time is spent in the Execution and Details stages, and the Execution stage is typically responsible for the final error handling and making decisions about whether to exit the application. So we need to ensure that the error handling drops back to the C++ in the right ways.

Caller stage

  • dl-serve
    • Calls service::listen() and checks boolean return
    • Raises RuntimeError to exit if necessary

Execution stage

See driplineorg/dripline-cpp#103

Details stage

  • ✅ AlertConsumer
    • Does not raise exceptions
  • ❌ Calibrate
    • calibration()
      • raises exceptions.DriplineValueError
      • This is the calibration decorator, which will be called when responding to a request
      • Therefore this is not the right use of DriplineValueError
  • ✅ Endpoint
    • Several functions
      • Raises only ThrowReply
  • ❓ Entity
    • Several functions
      • Raise ValueError
      • Question Is this right? Are these caught somewhere?
  • ✅ Interface
    • _send_request()
      • Raises DriplineError
      • Called by get(), set(), and cmd()
        • Not caught
        • Will pass exception up to the user of Interface
  • ✅ ReturnCodes.py
    • Does not raise exceptions
  • ✅ ThrowReply
    • Does not raise exceptions

I have not checked any code in Implementations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions