Effective Error Reporting

One thing we all agree - Big IronPython codes are boomerang. They Always Come Back to Developer 🥺
The real problem is there is no perfect code ☹️,
What we can do is - do a better Error Reporting to minimize time required to pin point issue. For this purpose, I usually take help of traceback and NotificationService Modules in code ✅
Have a look at example code -
import traceback
from Spotfire.Dxp.Framework.ApplicationModel import NotificationService
notif = Application.GetService[NotificationService]()

try:
a = 1/0 
#Raising Devide by Zero 
except:
tb = traceback.format_exc()
finally:
print tb
notif.AddErrorNotification("Error While Executing","IronPython Code <Name of Script> raised an Error",tb)

See, How it looks  -
Hope it helps 🤓
Share: