# Fail ignoring java.lang.IllegalStateException Error

**URL:** <https://forum.inductiveautomation.com/t/fail-ignoring-java-lang-illegalstateexception-error/33762>\
**Category:** Ignition\
**Created:** [April 8, 2020, 1:12am UTC](https://forum.inductiveautomation.com/t/fail-ignoring-java-lang-illegalstateexception-error/33762 "2020-04-08T01:12:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [April 8, 2020, 1:12am UTC](https://forum.inductiveautomation.com/t/fail-ignoring-java-lang-illegalstateexception-error/33762/1 "2020-04-08T01:12:14Z")

</div>

I want to Ignore an error, I tried using: `try: except:` schema.

I’m using the `system.gui.transform()` in:  
`
import java
try:
system.gui.transform(component=event.source, newWidth=100, duration=2000, callback=lambda: system.gui.transform(component=event.source, newWidth=200))
except java.lang.IllegalStateException:
print ‘Do nothing’
`

But error persists  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/555c6f12422e95a0e6fcfe5e321fcd6f7b86debb.png)

please help

---

<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:** [April 8, 2020, 1:17am UTC](https://forum.inductiveautomation.com/t/fail-ignoring-java-lang-illegalstateexception-error/33762/2 "2020-04-08T01:17:32Z")

</div>

The lambda isn’t running in the context of the try. It’s running in the callback context. You’ll probably have to use a full function definition with a nested try: catch: construct instead of a lambda.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [April 8, 2020, 2:11am UTC](https://forum.inductiveautomation.com/t/fail-ignoring-java-lang-illegalstateexception-error/33762/3 "2020-04-08T02:11:37Z")

</div>

sir @pturmel. Can you please tell me how?

If I understood…  
`def callbackCatch():
try:
system.gui.transform(component=event.source, newWidth=200)
except:
print ‘Do nothing and close def’`  
`
system.gui.transform(component=event.source, newWidth=100, duration=2000, callback=callbackCatch())
`

like that??  
I already tried it but the callback never happens!!

Mr. @pturmel is there a difference between catch: and except:?

Thanks for reply!!

---

<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:** [April 8, 2020, 11:44am UTC](https://forum.inductiveautomation.com/t/fail-ignoring-java-lang-illegalstateexception-error/33762/4 "2020-04-08T11:44:10Z")

</div>

Sorry “catch” is what other languages use. Python uses “except”. I think your only mistake is putting a pair of parentheses on callbackCatch where you use it. When passing a function to be called later, leave off the parentheses.

And please edit your posts to use code formatting blocks, using triple backquotes, like so:  
```  
pasted code  
```

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [April 8, 2020, 2:18pm UTC](https://forum.inductiveautomation.com/t/fail-ignoring-java-lang-illegalstateexception-error/33762/5 "2020-04-08T14:18:34Z")

</div>

Thanks Mr. @pturmel, it works like a charm

```auto
print 'Thanks' 

```
