# Global hooks/exception handlers for event scripts

**URL:** <https://forum.inductiveautomation.com/t/global-hooks-exception-handlers-for-event-scripts/5182>\
**Category:** Ignition\
**Created:** [September 25, 2012, 2:45pm UTC](https://forum.inductiveautomation.com/t/global-hooks-exception-handlers-for-event-scripts/5182 "2012-09-25T14:45:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [September 25, 2012, 2:45pm UTC](https://forum.inductiveautomation.com/t/global-hooks-exception-handlers-for-event-scripts/5182/1 "2012-09-25T14:45:32Z")

</div>

At the moment most of our event scripts look like this:

```auto
from app import dc
e = dc.Event(event)
try:
    # do stuff
except:
    e.error()
```

dc.Event is a wrapper around the event object that provides various shortcut methods.  
e.error() is a nice error handler that logs to the database and hides the stack trace from the user.

Is there any way to hook this in globally so that it will be used for all event handlers without having to add this boilerplate every time?

Thanks.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 26, 2012, 3:02am UTC](https://forum.inductiveautomation.com/t/global-hooks-exception-handlers-for-event-scripts/5182/2 "2012-09-26T03:02:02Z")

</div>

Not really. You would have to have a boilerplate for something whether it is the try…except or creating a function to pass in.

---

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [September 26, 2012, 8:36am UTC](https://forum.inductiveautomation.com/t/global-hooks-exception-handlers-for-event-scripts/5182/3 "2012-09-26T08:36:02Z")

</div>

I hadn’t considered passing a function. That might be a nice improvement.

```auto
def handler(event):
    pass

app.event.run(handler, event)
```

Actually, this has the added bonus of avoiding some of the module scoping issues.

Thanks.
