I would like to show the SQL error to the user in a text box instead of a error box popping up, but I cannot seem to find where to find the string with the specific error information.
import sys
try:
system.db.runPrepQuery("SQL Query with an error",[])
except:
print sys.exc_info()[0]
print sys.exc_info()[1]
print sys.exc_info()[2]
the sys variables I am printing out above do not show the error message coming back from the database.
Thank you,
You need to capture the actual exception Java threw.
import sys, java, java.lang
try:
system.db.runPrepQuery("SQL Query with an error",[])
except java.lang.Exception, javaerror:
print javaerror.getCause()
If you outputting to a text area you need to coerce everything to string:
import sys
try:
system.db.runPrepQuery("SQL Query with an error",[])
except:
event.source.parent.getComponent('Text Area').text= str(sys.exc_info()[0])+"\n"+str(sys.exc_info()[1])+"\n"+str(sys.exc_info()[2])
print, whilst running in a project, outputs to the console, not to a component.
Or, if you wanted it in an errorBox:
[code]import sys
try:
system.db.runPrepQuery(“SQL Query with an error”,[])
except:
system.gui.errorBox(str(sys.exc_info()[0])+"\n"+str(sys.exc_info()[1])+"\n"+str(sys.exc_info()[2]))
[/code]