# Error manangment during eam.sendRequest

**URL:** <https://forum.inductiveautomation.com/t/error-manangment-during-eam-sendrequest/87488>\
**Category:** Ignition\
**Created:** [March 18, 2024, 2:17pm UTC](https://forum.inductiveautomation.com/t/error-manangment-during-eam-sendrequest/87488 "2024-03-18T14:17:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [March 18, 2024, 2:17pm UTC](https://forum.inductiveautomation.com/t/error-manangment-during-eam-sendrequest/87488/1 "2024-03-18T14:17:52Z")

</div>

I have a remote agent and it is missing a message handler. This is by design. I will add the message handler later but in the meantime I want to capture the error that the sendRequest throws in the following try/except. However the following does not capture this error like I expect. In this case the error text should log and instead I get the normal pop up with a bunch of red with a clear description that the message handler does not exist on the remote gateway. Is there a way to capture this type of error?

```
result = None
try:
	result = system.util.sendRequest(project, messageHandler, payload, agent, timeoutSec)
except Exception as e:
	L.warn("An error occured while sending '%s' to '%s'" % (functionName, agent))
	L.warn("Error: %s" % str(e))
return result

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 18, 2024, 2:21pm UTC](https://forum.inductiveautomation.com/t/error-manangment-during-eam-sendrequest/87488/2 "2024-03-18T14:21:25Z")

</div>

This may be a case where you need to catch java.lang.Exception as well:

> [@Failing to catch exceptions from smart card reader](https://forum.inductiveautomation.com/t/failing-to-catch-exceptions-from-smart-card-reader/19819/6):
>
> Set up two clauses, like so:
> 
> ```auto
> # Important! Do not use "from java.lang import Exception", as that will
> # hide access to jython's Exception class.
> import java.lang.Exception
> 
> def something():
> try:
> # do something
> pass
> except java.lang.Exception, e:
> # Handle java exceptions
> # follow e.cause, e.cause.cause, .... to examine nested exceptions
> pass
> except Exception, e:
> # Handle jython exceptions
> pass
> 
> ```

---

<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:** [March 18, 2024, 6:26pm UTC](https://forum.inductiveautomation.com/t/error-manangment-during-eam-sendrequest/87488/3 "2024-03-18T18:26:52Z")

</div>

Nowadays I recommend catching `java.lang.Throwable` instead of `java.lang.Exception`. For two reasons:

- Catch pesky java **errors** , too.

- No name conflict with pythons own exception name, so you can `from java.lang import Throwable`.
