# Customized Default Exception Handling

**URL:** <https://forum.inductiveautomation.com/t/customized-default-exception-handling/64438>\
**Category:** Ignition\
**Tags:** vision, scripting, perspective\
**Created:** [September 23, 2022, 9:56pm UTC](https://forum.inductiveautomation.com/t/customized-default-exception-handling/64438 "2022-09-23T21:56:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [September 23, 2022, 9:56pm UTC](https://forum.inductiveautomation.com/t/customized-default-exception-handling/64438/1 "2022-09-23T21:56:26Z")

</div>

> [@How to learn perspective the right way?](https://forum.inductiveautomation.com/t/how-to-learn-perspective-the-right-way/64362/21):
>
> For that I wrap my whole script content in try except blocks

I have always wondered about customizing the default exception handling when in the perspective context.... Can someone tell me why this is a bad idea?

### Something akin to:

```python
import sys

# If perspective scripting is available in this context
if hasattr(system, 'perspective'):
    sys.excepthook = lambda type, exception, traceback : myFunctionToShowUserError(type, exception, traceback)

```

@pturmel I feel like you'd know this for Vision, maybe the answer applies in Perspective as well.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [September 23, 2022, 10:30pm UTC](https://forum.inductiveautomation.com/t/customized-default-exception-handling/64438/2 "2022-09-23T22:30:55Z")

</div>

To note, in my efforts, I haven’t got my exact example to work how I am expecting it.

However I know its possible if I dig around enough! Just need to find the right type of exception to override… lol

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 23, 2022, 10:35pm UTC](https://forum.inductiveautomation.com/t/customized-default-exception-handling/64438/3 "2022-09-23T22:35:32Z")

</div>

Well, even if this works, it won’t just be Perspective, it’ll be everything on the gateway. Possibly isolated to within a particular project’s “script manager”?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 23, 2022, 11:16pm UTC](https://forum.inductiveautomation.com/t/customized-default-exception-handling/64438/4 "2022-09-23T23:16:03Z")

</div>

> [@paul-griffith](#):
>
> it’ll be everything on the gateway

Well, everything **Jython**. I wouldn't expect it to catch Java exceptions.
