Skip to content

Updating the exception class #639

@jonathf

Description

@jonathf

Topic for discussion.

How do we feel about refactoring the current implementation of Exception?

  1. Could we add a what method to the exception? It is required if pybind11 is to retrieve the underlying error message. This is as far as I can tell also idiomatic C++.

  2. How do we feel about adding three subclasses: InputException InternalException RoutingExeption which hardcodes ERROR in their constructors? (Or perhaps deprecate the ERROR enum if it is no longer needed.) We then use the specific exceptions around in the codebase. It also works better on the Python side of things where the visual error representation is quite important.

  3. An idea BTW that also is perhaps worth considering: Adding a unsigned exit_code attribute to the exception directly.
    This way you can do:

    } catch (const vroom::Exception& e) {
         std::cerr << "[Error] " << e.message << std::endl;
         vroom::io::write_to_json({e.error_code, e.message},
                             false,
                             cl_args.output_file);
    

    and you can replace:

    //auto error_code = vroom::utils::get_code(vroom::ERROR::ROUTING);
    auto error_code = vroom::RoutingException().error_code

    get_code then becomes obsolete and can be removed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions