try-catch doesn’t work with connector call
-
Klaus79vor 3 Jahren #25684
Hi,
I’m calling a connector inside business object inside a try-catch-block
try{
Simplifier.Connector(…)
}
catch {e}
Connector exits with an error because of a duplicate entry in database (connector method consists of a sql insert operation).
I assumed that this error message is catched by ‘e’.
But ‘e’ is <undefined>.
Could anyone help?
Best regards
Klaus
KahnHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Klaus79vor 3 Jahren #25689::Hi Kahn,
here it is:
try {
var resultConnector = Simplifier.Connector.DataLoad.saveT002FromSAP({
CustID: input.CustID,
SystemID: input.SystemID,
params: dataset
});
Simplifier.Log.debug(“resultConnector”, resultConnector);
insertedID = resultConnector.generatedID;} catch (e) {
//error is catched but ‘e’ is <undefined>
Simplifier.Log.debug(“error in connector call”, e);
message_text = e.message;
message_name = e.name;
}The result of the connector:
{
“message”: “Duplicate entry ‘1-3-D’ for key ‘PRIMARY'”,
“success”: false
}Best regards
Klaus
Armin WinklerHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)vor 3 Jahren #25691::Hi Klaus,
just like Kahn mentioned, I was able to adapt your BO function writeLogEntry inside of the BO DB_Log so that it outputs the error message received from the failed connector call. While the error object e itself is undefined, the message itself can indeed be accessed and printed out as a log. I left the necessary line of code in the BO script for you but commented it out, hope this helps you.
Regards,
Armin
You must be logged in to reply to this topic.