Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Forum try catch block

  • try catch block

    Posted by Scott on September 16, 2020 at 10:53 pm

    Hey everyone, I was curious if anyone has found a substitute for try catch block in Omnis? I’ve tried a few things, but I really don’t see anything that could server the same purpose. Currently we are using Omnis 10.1.

    Scott replied 3 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Paul Mulroney

    September 17, 2020 at 1:47 am

    Hi Scott,
    It’s not ideal, but how about “Load Error Handler”? eg
    Load error handler ccPWM/ErrorHandler (first error, last error)
    After that have your code. If you want to catch OS level events like timeouts etc, it should happen automatically. If you want to create your own custom errors, you can eg
    Signal error {27,"Something bad happened, Err 27"}
    When done,
    Unload error handler ccPWM/ErrorHandler
    In your error handler, you can then take whatever action necessary, and include eg
    SEA continue execution
    You can test the #ERRCODE and #ERRTEXT for specific errors eg
    Switch #ERRCODE
    Case 27
    ; Our special error signal
    Case kerrBadnotation
    ; Notation error
    Case kerrDiskfull
    ; OS file ops related
    ; All other cases here
    End Switch
    SEA continue execution
    Hope this helps!

  • Scott

    September 17, 2020 at 4:44 pm

    Thanks Paul, it’s an interesting substitute. Not sure why they strayed from the traditional try/catch, but I am happy to have something that will do the trick. I gave it a try and it does seems to work. Hopefully it holds up in the wild. Much appreciate it!

Log in to reply.