With all this error talk.. - Forum - OpenEdge Development - Progress Community
 Forum

With all this error talk..

  • I don't think this is the best coding style for error handling, but am curious. Why doesn't the return value get populated from 'doIt'?  Does the RETURN simply become unreachable code?

    DEFINE VARIABLE cError AS CHARACTER NO-UNDO.
    
    RUN doIt.
    
    MESSAGE RETURN-VALUE VIEW-AS ALERT-BOX.
    
    PROCEDURE doIt:
    
      DEFINE VARIABLE cValue AS CHARACTER NO-UNDO.
    
      FIND customer NO-LOCK
        WHERE customer.Name = "buttface".
    
      RETURN cValue.
    
      CATCH e AS PROGRESS.Lang.SysError:
        cValue = e:getMessage(1).
      END CATCH.
    
    END PROCEDURE.

    Jeff Ledbetter
    Product Architect | Roundtable Software

  • Yes.
     
    From: Jeff Ledbetter [mailto:bounce-jeffledbetter@community.progress.com]
    Sent: Tuesday, 19 May, 2015 14:55
    To: TU.OE.Development@community.progress.com
    Subject: [Technical Users - OE Development] With all this error talk..
     
    Thread created by Jeff Ledbetter

    I don't think this is the best coding style for error handling, but am curious. Why doesn't the return value get populated from 'doIt'?  Does the RETURN simply become unreachable code?

    DEFINE VARIABLE cError AS CHARACTER NO-UNDO.
     
    RUN doIt.
     
    MESSAGE RETURN-VALUE VIEW-AS ALERT-BOX.
     
    PROCEDURE doIt:
     
      DEFINE VARIABLE cValue AS CHARACTER NO-UNDO.
     
      FIND customer NO-LOCK
        WHERE customer.Name = "buttface".
     
      RETURN cValue.
     
      CATCH e AS PROGRESS.Lang.SysError:
        cValue = e:getMessage(1).
      END CATCH.
     
    END PROCEDURE.
    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

  • Slightly less tersely ... when the error occurs, it jumps to the catch, right over the return.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • Ok, let’s change it up.
     
    Why does this work then? The go4It procedure catches the thrown error, but the RETURN is processed because the main-block get the return-value.
     
     
    RUN go4It.
     
    MESSAGE RETURN-VALUE VIEW-AS ALERT-BOX TITLE "Main Block".
     
    PROCEDURE go4It:
     
      DEFINE VARIABLE cError AS CHARACTER   NO-UNDO.
     
      RUN doIt.
     
      RETURN cError.
     
      CATCH e AS PROGRESS.Lang.AppError:
        cError = e:returnValue.
      END CATCH.
     
    END PROCEDURE.
     
    PROCEDURE doIt:
     
      DEFINE VARIABLE cValue AS CHARACTER NO-UNDO.
     
      DO ON ERROR UNDO:
     
        FIND customer NO-LOCK
          WHERE customer.Name = "buttface".
     
        CATCH e AS PROGRESS.Lang.SysError:
         cValue = e:getMessage(1).
        END CATCH.
     
      END.
     
      RETURN ERROR cValue.
     
    END PROCEDURE.
     
    Jeff Ledbetter
    skype: jeff.ledbetter
     
    From: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
    Sent: Tuesday, May 19, 2015 2:07 PM
    To: TU.OE.Development@community.progress.com
    Subject: RE: [Technical Users - OE Development] With all this error talk..
     
    Reply by Thomas Mercer-Hursh

    Slightly less tersely ... when the error occurs, it jumps to the catch, right over the return.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Jeff Ledbetter
    Product Architect | Roundtable Software

  • Never mind. It doesn’t work. The RETURN-VALUE is just left hanging around. Makes more sense now.
     
    Jeff Ledbetter
    skype: jeff.ledbetter
     
    From: Jeff Ledbetter [mailto:bounce-jeffledbetter@community.progress.com]
    Sent: Tuesday, May 19, 2015 2:17 PM
    To: TU.OE.Development@community.progress.com
    Subject: RE: [Technical Users - OE Development] With all this error talk..
     
    Reply by Jeff Ledbetter
    Ok, let’s change it up.
     
    Why does this work then? The go4It procedure catches the thrown error, but the RETURN is processed because the main-block get the return-value.
     
     
    RUN go4It.
     
    MESSAGE RETURN-VALUE VIEW-AS ALERT-BOX TITLE "Main Block".
     
    PROCEDURE go4It:
     
      DEFINE VARIABLE cError AS CHARACTER   NO-UNDO.
     
      RUN doIt.
     
      RETURN cError.
     
      CATCH e AS PROGRESS.Lang.AppError:
        cError = e:returnValue.
      END CATCH.
     
    END PROCEDURE.
     
    PROCEDURE doIt:
     
      DEFINE VARIABLE cValue AS CHARACTER NO-UNDO.
     
      DO ON ERROR UNDO:
     
        FIND customer NO-LOCK
          WHERE customer.Name = "buttface".
     
        CATCH e AS PROGRESS.Lang.SysError:
         cValue = e:getMessage(1).
        END CATCH.
     
      END.
     
      RETURN ERROR cValue.
     
    END PROCEDURE.
     
    Jeff Ledbetter
    skype: jeff.ledbetter
     
    From: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
    Sent: Tuesday, May 19, 2015 2:07 PM
    To: TU.OE.Development@community.progress.com
    Subject: RE: [Technical Users - OE Development] With all this error talk..
     
    Reply by Thomas Mercer-Hursh

    Slightly less tersely ... when the error occurs, it jumps to the catch, right over the return.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Jeff Ledbetter
    Product Architect | Roundtable Software

  • I do recommend the little box at the right end of the rich formatting screen for posting code.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • I don’t see that little box here in my Outlook client…
     
    Jeff Ledbetter
    skype: jeff.ledbetter
     
    From: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
    Sent: Tuesday, May 19, 2015 2:34 PM
    To: TU.OE.Development@community.progress.com
    Subject: RE: [Technical Users - OE Development] With all this error talk..
     
    Reply by Thomas Mercer-Hursh

    I do recommend the little box at the right end of the rich formatting screen for posting code.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Jeff Ledbetter
    Product Architect | Roundtable Software

  • that's because you used "buttface" ;)

    doing stuff with MyLittlePony would never raise an error ...

  • Jeff, if you click Use Rich Formatting at the bottom right you get a box with two lines of icons on the top strip.  The rightmost icon on the lower row looks like a square with a pencil in it.  That's the one.  It gives you a box you can past the code into and pick the language.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • You got a pony?
    Von: jmls [mailto:bounce-jmls@community.progress.com]
    Gesendet: Dienstag, 19. Mai 2015 21:49
    An: TU.OE.Development@community.progress.com
    Betreff: RE: [Technical Users - OE Development] With all this error talk..
     
    Reply by jmls

    that's because you used "buttface" ;)

    doing stuff with MyLittlePony would never raise an error ...

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • Yes, I used that the first time. It’s only via the forum UI. My follow up replies have been via email.
     
    Jeff Ledbetter
    skype: jeff.ledbetter
     
    From: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
    Sent: Tuesday, May 19, 2015 2:53 PM
    To: TU.OE.Development@community.progress.com
    Subject: RE: [Technical Users - OE Development] With all this error talk..
     
    Reply by Thomas Mercer-Hursh

    Jeff, if you click Use Rich Formatting at the bottom right you get a box with two lines of icons on the top strip.  The rightmost icon on the lower row looks like a square with a pencil in it.  That's the one.  It gives you a box you can past the code into and pick the language.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Jeff Ledbetter
    Product Architect | Roundtable Software

  • Buttface was the cleaned up version..  my lint tool doesn’t allow swear words. ;)
     
    Jeff Ledbetter
    skype: jeff.ledbetter
     
    From: jmls [mailto:bounce-jmls@community.progress.com]
    Sent: Tuesday, May 19, 2015 2:49 PM
    To: TU.OE.Development@community.progress.com
    Subject: RE: [Technical Users - OE Development] With all this error talk..
     
    Reply by jmls

    that's because you used "buttface" ;)

    doing stuff with MyLittlePony would never raise an error ...

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Jeff Ledbetter
    Product Architect | Roundtable Software

  • So, posting code is a good reason not to reply by e-mail ... :)

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • You guys are so entertaining!

  • it was taken away from me ...