Skip to content

User defined exceptions show as Unknown in redun console #111

@tesujimath

Description

@tesujimath

Actually, it's not all user defined exceptions which do this. It's any exception class for which the constructor has multiple required parameters.

I fixed it in my case by defining default values for all but the first parameter in the constructor for the exception. Like this:

class MyCalledProcessError(Exception):
    def __init__(self, stderr: str | bytes, returncode: int = 0, cmd: List[str] = []):
        """To avoid showing as Unknown in redun console, the constructor must have only one parameter without default value."""
        self.stderr = stderr
        self.returncode = returncode
        self.cmd = cmd
        super().__init__(str(self))

My guess is that deserializing the exception from the redun database for use in the console is failing because it tries to create the exception object with only a single parameter before populating the rest. But that is a guess, I didn't have a close look at how that works.

If it is fixable that would be great. Otherwise this issue can help others who stumble over the same behaviour.

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