Skip to content

Raise explicit errors gracefully instead of returning SystemError code 1 #87

@Luispain

Description

@Luispain

Dear all,

This ticket is to request for having explicit error handling, for allowing Python interrupt gracefully with relevant exception types and error message, instead of interrupting the simulation in a hard way such as in:

E             File "/stck/cassiope/git/Cassiopee/Dist/bin/ld/lib/python3.8/site-packages/FastS/PyTree.py", line 2073, in display_temporal_criteria
E               import sys; sys.exit(1) # return 1 to shell
E           SystemExit: 1

Where we have:

    if stopAtNan:
        finite = Cmpi.isFinite(t, var='centers:Density')
        if not finite:
            import sys; sys.exit(1) # return 1 to shell

At least I would rather prefer something like:

    if stopAtNan:
        finite = Cmpi.isFinite(t, var='centers:Density')
        if not finite:
            raise ValueError("NaN where detected at Density field")

Which explicitly tells what fails, and it is easier to handle the exception through try/except blocks, or other exception handling mechanisms.

It would be easier because we can automatically know what actually caused the solver to crash, because using try/except handling for SystemError with value 1 does not tell much of what caused the problem.

Best regards

Luis

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