Get component action and page from the python exception stack

in script, how to get in script: component action and page from the python exception stack

For example, when an exception is triggered:

Error running action 'component.onActionPerformed' on pages/test@D/root/Button_2:
Traceback (most recent call last): File "<function:runAction>", line 7, in runAction UnboundLocalError: local variable 'test' referenced before assignment

I would like to add some context information in my logger error message

Those are from the thread-local MDC, and should already be annotating your log messages.

yes I see, the only missing part is for example the information like action 'component.onActionPerformed'

You can't, from scripting. The internal classes, hidden behind the SafetyWrapper implementations, do it via a method on AuditingContext, basically.