Skip to content

Error handling {c,sh}ould be improved #200

@dpaetzel

Description

@dpaetzel

Disclaimer: Solving this may be quite a pain and time consuming and not much fun.

I often stumble over the fact that the C code calls exit(EXIT_FAILURE). I understand that this is probably for historic reasons (Python bindings were added later) but this regularly kills my interactive Python (or Julia) session (i.e. instead of an exception being thrown, the entire session ends). In Python this isn't that bad, because you can start a new session rather quickly (if you keep a scratch pad of what you entered nearby—or use Jupyter or something, I guess) but for Julia this is quite unfortunate because restarting a session can take quite a few seconds due to precompilation etc.

What would need to be changed? If the current code style (mostly C) should be kept, then all exit(…)s would need to be replaced, e.g. by the surrounding function returning an int status instead of void and that would have to be propagated up to 1) main (for pure C stuff) and 2) the Python bindings. There the error could be rethrown either as exit(…) or using pybind exceptions. Maybe this can be done simpler by switching to C++ features but that would still require many changes, I guess.

I just thought I'd report this, because it's a regularly occurring problem for me. Feel free to close for reasons of “no intent to support this”. 🙂

This may also have been a topic of discussion somewhere in this repo but I couldn't find a proper writeup.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions