# Try...Except - Help displaying more info

**URL:** <https://forum.inductiveautomation.com/t/try-except-help-displaying-more-info/10893>\
**Category:** Ignition\
**Created:** [December 9, 2015, 1:43pm UTC](https://forum.inductiveautomation.com/t/try-except-help-displaying-more-info/10893 "2015-12-09T13:43:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scicco](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@scicco](https://forum.inductiveautomation.com/u/scicco)\
**Post date:** [December 9, 2015, 1:43pm UTC](https://forum.inductiveautomation.com/t/try-except-help-displaying-more-info/10893/1 "2015-12-09T13:43:53Z")

</div>

Hello,

I’m trying to display more information from an Exception in a messageBox instead of the Ignition error window. The java.lang Exception is from execSProcCall but in that stored procedure I’m raising specific errors in my T-SQL logic. The message I want to display is caused by a GatewayException but I don’t know how to get that value. Here is my code:

```auto
from java.lang import Exception

if event.keyCode == event.VK_ENTER:
	try:		
		call = system.db.createSProcCall("dbo.usp_Handle_Badge_Swipe")
		call.registerInParam(1, system.db.TINYINT, event.source.parent.Badge_ID)
		system.db.execSProcCall(call)
	except Exception, value:
		from com.inductiveautomation.ignition.client.gateway_interface import GatewayException
		system.gui.messageBox("Error: %s" % value) #I want the GatewayException value, not the Exception value here

```

This returns a messageBox with what’s expected - “Error: java.lang.Exception: Error executing system.db.execSProcCall()”. But what I’m after is the following error raised in my stored procedure and I don’t know the syntax to get it:

Caused by: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: Badge 123456 is not valid for any user.

Thanks in advance,  
Steve

---

<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:** [December 9, 2015, 2:59pm UTC](https://forum.inductiveautomation.com/t/try-except-help-displaying-more-info/10893/2 "2015-12-09T14:59:27Z")

</div>

Note the “Caused by”.[quote=“scicco”]Caused by: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: Badge 123456 is not valid for any user.[/quote]That’s the key to your problem. Java exceptions can have nested exceptions as their ‘cause’. So you should be doing something like:`if event.keyCode == event.VK_ENTER:
	call = system.db.createSProcCall("dbo.usp_Handle_Badge_Swipe")
	call.registerInParam(1, system.db.TINYINT, event.source.parent.Badge_ID)
	try:
		system.db.execSProcCall(call)
	except Exception, value:
		system.gui.messageBox("Error: %s" % value.getCause())`I also moved your call setup instructions outside of the try. In general, you should only wrap what you expect to handle.

---

<div class="post-metadata">

**Author:** ![scicco](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@scicco](https://forum.inductiveautomation.com/u/scicco)\
**Post date:** [December 9, 2015, 3:08pm UTC](https://forum.inductiveautomation.com/t/try-except-help-displaying-more-info/10893/3 "2015-12-09T15:08:57Z")

</div>

Exactly what I needed - thank you!
