InterSystems FAQ rubric
This can be done with TRY-CATCH:
#dim ex As %Exception.AbstractException
TRY {
//Code that causes an error
}
CATCH ex {
do ex.Log()
}
If you use ^%ETN, call it from the BACK entry (BACK^%ETN).
Please also take a look at the related article: How to get application errors (^ERRORS) using a command