Catch and Throw

jmac13

Member
Hi All,

I'm using open edge 10.2b I cant seem to throw errors.. can someone point out what im doing wrong. (this code is just a test) I've got a repeat look and i run test which is procedure within my .w which has a catch in for a find first that will fail and it should then throw it up to catch that ive got within my repeat loop but this doesnt seem to happen.

Code:
do on error undo, leave on stop undo, leave:
    repeat:


       run test.

       catch ErrMessage AS Progress.Lang.ProError:
         message "Error Happened"
                 view-as alert-box information
                 buttons ok.

        message ErrMessage:GetMessage(1) view-as alert-box buttons ok.

       end catch.

    end.

end.


/*Test procdure*/
PROCEDURE test :

  DO ON ERROR UNDO, LEAVE:
      FIND grades where grades.grade = "ASDSADSAD".
     
     catch e AS Progress.Lang.ProError:
         UNDO, THROW e.
      END CATCH.
   END.



END PROCEDURE.
 
I think what you miss is the
Code:
ROUTINE-LEVEL ON ERROR UNDO, THROW.
statement. It must be the first statement in the procedure. AFAIK, otherwise the "catch chain" is broken because the test internal procedure is the next outer block which doesn't catch your exception.

Heavy Regards, RealHeavyDude.
 
Thanks RDH that would be it.. Tom has mentioned that to me before.. If i had that i wouldnt need the catch as such as it would throw the error anyway and the default for blocks? I guess i need to understand better what is in each block..dont really understand how
 
Back
Top