How to: Add exception traceback
It can be useful to log and pass back the exception description and traceback associated with your calculation.
The snippet below shows how we can use a try-except statement to add exception information to the ArupComputeResult
object returned by the calculation:
import traceback # built-in module
def divide(dividend: float, divisor: float) -> ArupComputeResult:
acr = ArupComputeResult()
try:
quotient = dividend / divisor
acri = ArupComputeResultItem()
acri.symbol = "quotient"
acri.value = quotient
acr.arupComputeResultItems.append(acri)
except Exception:
acr.errors.append(traceback.format_exc()) # add traceback to AC errors
return acr
return acr