# Python script Try Except + logging exception

**URL:** <https://forum.inductiveautomation.com/t/python-script-try-except-logging-exception/48160>\
**Category:** Ignition\
**Created:** [June 24, 2021, 2:53pm UTC](https://forum.inductiveautomation.com/t/python-script-try-except-logging-exception/48160 "2021-06-24T14:53:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sydney.bergeron](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sydney.bergeron](https://forum.inductiveautomation.com/u/sydney.bergeron)\
**Post date:** [June 24, 2021, 2:53pm UTC](https://forum.inductiveautomation.com/t/python-script-try-except-logging-exception/48160/1 "2021-06-24T14:53:52Z")

</div>

I’ve got a python script running a named query, I’m trying to catch any exceptions thrown and log an error to the wrapper logs.

This works when I just use  
try:  
except:

However, I’d like to be able to log the exception message. But if I use:  
try:  
except Exception, e:

not ALL exceptions are caught anymore… is there any other generic “Exception” type that I need to use to catch all exceptions and log the message?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 24, 2021, 3:10pm UTC](https://forum.inductiveautomation.com/t/python-script-try-except-logging-exception/48160/3 "2021-06-24T15:10:03Z")

</div>

> [@Catch IOException?](http://forum.inductiveautomation.com/t/catch-ioexception/18612/3):
>
> Consider using two except blocks, as jython’s standard Exception won’t catch pure java exceptions. Like so: import java.lang.Exception try: # something something something except Exception, e: # jython exception except java.lang.Exception, e: # java exception
