Forum Discussion

itaykaldi's avatar
itaykaldi
Contributor
11 years ago
Solved

handle run time error

hey,

i created keyword test, in the keyword test i call to some script with try and catch.

the script throw exception, but the keyword script doens't handle it.

the test stop and show run time error window.



i can fix it only if i use in try and catch in the script. (i want the test will not stop..).



Is there another solution?



10x.



  • You can cancel stop on error in the project properties, but your best option is probably the try and catch.

    In anycase it will be best if you ensure that the script will not throw exceptions (add verifications etc..).

9 Replies

  • You can cancel stop on error in the project properties, but your best option is probably the try and catch.

    In anycase it will be best if you ensure that the script will not throw exceptions (add verifications etc..).

  • hey,

    i already cancel stop on error. but not work on run time error :(





  • Ravik's avatar
    Ravik
    Super Contributor
    Hi.



    1-You can use "On Error Reusem Next" method, if you are using VBScript.

    2- you can use "Try.. Catch" If you are using JavaScript or any like C#.



    It will catch your run time exception and without stopping script it will move on next action.



    • vgangavarapu198's avatar
      vgangavarapu198
      Occasional Contributor
      Hi Ravi,

      Is it possible to use "On Error Resume Next " for 10 times within the same function...
      Is there any other alternative for On Error... in VA Script...
      The reason why I am asking you is , I have function with 10 lines of code . I need to check on each line of code if it has error or not...

      Please help ...
      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        In VBScript, think of it as a switch.

         

        "On Error Resume Next" - switches error handling off. If something fails once set, it will just keep going.

         

        With it switched off, error codes will still be captured. You can check the value of "Err.Number" - the code should indicate the naurture of the error, but you need to handle it with your own code when running this way. (List of error codes: http://ss64.com/vb/syntax-errors.html )

         

        "On Error Goto 0" - switches it back on.

         

        If you switch error handling off, you need to make sure your code is robust and/or you include your own error handling. If you just let it plough merrily on no matter what, without doing any sort of validation or error handling yourself, you can produce some very stange results ....