I have an automation script that I am working on that implements a REST API request. I'm having a problem trapping exceptions coming from java method calls. In this case, I am calling the add() method on an mbo opened on the PLUSDESTVERSION table. There is a custom java validation that throws an exception if the value assigned to the WORKGROUP field isn't a valid record. I have added multiple levels of "try/except" blocks around the add() call, but the except blocks aren't getting invoked, and my REST API call is returning a 400 status, with the response JSON body set to the data from the java error.
Here is the code:
try:
version = versionSet.add()
version.setValue("CONTRIBUTIONMETHOD", "N")
version.setValue("APPLYCONTRIBUTION", "N")
log("Before setValue(WORKGROUP)")
try:
version.setValue("WORKGROUP", parentWO.getString("OWNERGROUP"))
except Exception as addEx:
log_error("EXCEPTION during version.setValue(): {}".format(str(addEx)))
raise Exception("EXCEPTION during version.setValue(): {}".format(str(addEx)))
log("After setValue(WORKGROUP)")
version.setValue("OVERHEADTYPE", parentWO.getString("OPSSITEID"))
if ogsLvInitiatedCue == "Y":
version.setValue("STORELOC", storeLoc)
if opsSiteId == "ONG":
# Set default for ONG only
log("Setting PLUSDESTVERSION.OGSREIMBURSABLE for ONG")
version.setValue("OGSREIMBURSABLE", "No")
versionSet.save()
except Exception as addEx:
log_error("EXCEPTION during versionSet.add(): {}".format(str(addEx)))
raise Exception("EXCEPTION during versionSet.add(): {}".format(str(addEx)))
Rather than my exception message appearing in the REST call's response body, I'm getting this:
{
"Error": {
"errorattrname": "workgroup",
"extendedError": {
"moreInfo": {
"href": "http://localhost/maximo/api/error/messages/BMXAP0395E"
}
},
"correlationid": null,
"errattrvalue": null,
"reasonCode": "BMXAP0395E",
"message": "BMXAP0395E - Person Group OTRE is not a valid TnD Work Group.",
"statusCode": "400"
}
}
My log messages are also not getting written to SystemOut.log.
Is what I am doing correct? Or are automation scripts unable to trap exceptions from calls to IBM java classes?
#Customizations#Integrations------------------------------
Theo Pozzy
OneGas
------------------------------