Forum Simplifier Forum Connectors try-catch doesn’t work with connector call

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25684
    AvatarKlaus79
    Participant
    • Topics: 36
    • Replies: 45

    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

    #25687
    KahnKahn
    Moderator
      Has successfully completed the online course No-Code.
      Has successfully completed the online course Low-Code.
      Has successfully completed the online course Pro-Code.
    • Topics: 0
    • Replies: 58
    Up
    0
    Down

    Hello.

    can you please show the try-catch block.

    I have tried to access the message of a try catch block and it worked with a connector. You can only access the message of an error object.

    Best Regards

     

    #25689
    AvatarKlaus79
    Participant
    • Topics: 36
    • Replies: 45
    Up
    0
    Down

    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

    #25691
    ArminArmin
    Moderator
      Has successfully completed the online course No-Code.
      Has successfully completed the online course Low-Code.
      Has successfully completed the online course Pro-Code.
    • Topics: 0
    • Replies: 40
    Up
    0
    Down

    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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.