Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better display format for exceptions #71

Open
Almenon opened this issue Feb 10, 2019 · 2 comments
Open

better display format for exceptions #71

Almenon opened this issue Feb 10, 2019 · 2 comments

Comments

@Almenon
Copy link
Owner

Almenon commented Feb 10, 2019

Try capturing a exception into a var:

class myCustomException(Exception):
    pass

x = 5

try:
    raise myCustomException({'ts':5})
except myCustomException as e:
    x = e

print(dir(x))
@Almenon
Copy link
Owner Author

Almenon commented Feb 11, 2019

var output:

-{
    myCustomException: -{
        py/type: "__main__.myCustomException"
    },
    x: -{
        py/reduce: -[
           -{
                py/type: "__main__.myCustomException"
            },
           -{
                py/tuple: -[
                   +{1 items}
                ]
            },
            {},
            null,
            null
        ]
    }
}

@Almenon
Copy link
Owner Author

Almenon commented Feb 11, 2019

didn't work for some reason :/

class exceptionHandler(BaseHandler):
    def flatten(self, obj, data):
        return {
            "py/type": type(obj),
            "args": obj.args
        }

handlers = [
    {'type': Exception, 'handler': exceptionHandler},
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant