Xilinx / inference-server

https://xilinx.github.io/inference-server/
Apache License 2.0
43 stars 13 forks source link

Use better exceptions #33

Closed varunsh-xilinx closed 2 years ago

varunsh-xilinx commented 2 years ago

Summary of Changes

Closes #30

Motivation

Exceptions in the inference server were a mix of standard C++ exceptions but they were inconsistently used. By using custom exceptions, each exception gets a descriptive name and we can use them more consistently throughout. We can also move towards ensuring that any exceptions thrown into user code will be one of ours so they're easy to catch.

Implementation

New exceptions classes are added in a header file. They follow the naming syntax of existing C++ exceptions. In the Python bindings, the base class

Previously, workerReady, the internal version of modelReady would through an exception if a worker wasn't found. As this is a non-exceptional scenario, this case no longer throws an exception. Instead, it simply returns false. This change allows removing a number of try-catch blocks from the code.