When you catch the exception, you can cast it to a string, and get its type using type"
try:
raise ValueError("oops, a value was incorrect")
except ValueError as exc:
print(exc)
print(type(exc))
Accessing the entire traceback programmatically is currently not supported.
You can override the default error handler using set_default_error_handling:
# This code displays an Anvil alert, rather than
# the default red box, when an error occurs.
def error_handler(err):
alert(str(err), title="An error has occurred")
set_default_error_handling(error_handler)
Thanks shaun but I don’t think I was clear.
When I raise a custom error on the server and pass it a string, the error I catch on the client is a modified string. Anvil has changed it by concatenating the type and location.
I assume the custom error which is derived from AnvilWrappedError has properties that include the unmodified string but since pprint isn’t implemented on the client, I can’t easily dump its structure.
I can’t find documentation about the properties of AnvilWrappedError