try-catch doesn’t work with connector call

  • Klaus79
        vor 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

        Kahn
            Has successfully completed the online course Introduction
            Has successfully completed the online course Intermediate (200)
            Has successfully completed the online course Advanced (300)
          vor 3 Jahren #25687
          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

           

          Klaus79
              vor 3 Jahren #25689
              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

              Armin Winkler
                  Has successfully completed the online course Introduction
                  Has 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
                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

              Ansicht von 4 Beiträgen – 1 bis 4 (von insgesamt 4)

              You must be logged in to reply to this topic.