Handling custom exceptions

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)

See here in the docs.