Retrieve information from an exception

Hello,
I'd like to know how I can get a clean trace of exceptions thrown in a Python script in Zope5. I would like to know the type, and to have the traceback.
thank you in advance

What do you mean by "Python script"? Code of browser view or a ZMI "Python Script". All errors are usually logged to error_log in the ZMI and to the instance.log on the filesystem. What else is missing?

Install Products.SiteErrorLog and add a "Site Error Log" to your Zope root object (via the ZMI). This will add an object called error_log. There you find detailed information about most exceptions. The object's configuration determines which exception types are ignored.

Hello, we didn't understand each other. I am familiar with SiteErrorLog, but I want to retrieve a clear trace in a try / except in order to generate clear messages for users. Can we use traceback in zope?
Thank you

What is a "clear traceback"? As @dieter and myself wrote: all exception are logged in the site error log and inside the log file. What else is missing. Repeating the same question does not help without giving further explanations.

Look at Python's traceback module. Of course, you can use it in Zope, though not directly in restricted code. For use in restricted code, traceback behaves like any other module: it requires an allow_module; if you want to access traceback entry objects in restricted code, you may also need allow_type.

Ok,
Thanks

Plone Foundation Code of Conduct