Error or Progress.Lang.Error

Posted by Thomas Mercer-Hursh on 16-May-2015 10:57

This is probably just a matter of taste, but I am curious about other's reactions.  I am used to seeing catch blocks and the like written with Progress.Lang.Error, Progress.Lang.AppError, and Progress.Lang.SysError, but I encountered some code this morning which had using Progress.Lang.Error and using Progress.Lang.AppError and this allowed writing the catch blocks and throws as simply Error and AppError.  In general, I am a big fan of using to keep code readable, but seeing just plain Error bothered me since it seemed obscure, but perhaps that is just because I am used to seeing it spelled out.  AppError less so, but consistency would dictate one way or the other.

Thoughts?

All Replies

Posted by Richard Banville on 18-May-2015 07:51

I think you’d get a better response if you were to post this to the ABL lang community rather than the RDBMS community.
 
 
[collapse]
From: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
Sent: Saturday, May 16, 2015 11:58 AM
To: TU.OE.RDBMS@community.progress.com
Subject: [Technical Users - OE RDBMS] Error or Progress.Lang.Error
 
Thread created by Thomas Mercer-Hursh

This is probably just a matter of taste, but I am curious about other's reactions.  I am used to seeing catch blocks and the like written with Progress.Lang.Error, Progress.Lang.AppError, and Progress.Lang.SysError, but I encountered some code this morning which had using Progress.Lang.Error and using Progress.Lang.AppError and this allowed writing the catch blocks and throws as simply Error and AppError.  In general, I am a big fan of using to keep code readable, but seeing just plain Error bothered me since it seemed obscure, but perhaps that is just because I am used to seeing it spelled out.  AppError less so, but consistency would dictate one way or the other.

Thoughts?

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Thomas Mercer-Hursh on 18-May-2015 09:37

Dang, I thought I had.  Let me see if I can get Jean to move it to avoid duplication.

Posted by Thomas Mercer-Hursh on 18-May-2015 09:38

Wait a minute ... it says OpenEdge Development is the forum.  Sounds like the right place to me.

Posted by Peter Judge on 18-May-2015 09:38

Thomas,

It's moved.

Posted by Thomas Mercer-Hursh on 18-May-2015 09:43

That's sort of my question.  I.e., is just plain Error confusing compared to Progress.Lang.Error?  AppError and SysError certainly less so, but it seems like one should be consistent.

BTW, now I'm confused since I got a message this thread was moved and I saw it on the Development forum, but now it seems like this is on RDBMS.

Posted by Peter Judge on 18-May-2015 09:55

I think what happened with the forum switching is that I'd replied to your post of the RDBMS forum, then I moved your original post. You replied to my post and here we are again. I've moved this post too, so now we should be ok.

Posted by Peter Judge on 18-May-2015 09:55

IMO the main reason not to use USING is when you have to disambiguate for some reason: you want to use PLO and System.Object, or you have temp-table/db field names that clash with static member names.
 
If it's really confusing/misleading, then spell it out, otherwise  shorten.
 
-- peter
 
[collapse]
From: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
Sent: Saturday, 16 May, 2015 11:58
To: TU.OE.RDBMS@community.progress.com
Subject: [Technical Users - OE RDBMS] Error or Progress.Lang.Error
 
Thread created by Thomas Mercer-Hursh

This is probably just a matter of taste, but I am curious about other's reactions.  I am used to seeing catch blocks and the like written with Progress.Lang.Error, Progress.Lang.AppError, and Progress.Lang.SysError, but I encountered some code this morning which had using Progress.Lang.Error and using Progress.Lang.AppError and this allowed writing the catch blocks and throws as simply Error and AppError.  In general, I am a big fan of using to keep code readable, but seeing just plain Error bothered me since it seemed obscure, but perhaps that is just because I am used to seeing it spelled out.  AppError less so, but consistency would dictate one way or the other.

Thoughts?

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Jean Richert on 18-May-2015 10:11

[mention:6911e6cc8725416dba58ae08a80faffd:e9ed411860ed4f2ba0265705b8793d05] and [mention:9e4ee96fac634b8f91b580e1fb4f7e71:e9ed411860ed4f2ba0265705b8793d05] , apparently something went wrong when Peter answered back as his answer created a new thread... So I merged everything back.

Posted by Thomas Mercer-Hursh on 18-May-2015 10:20

And now, I'll need to create a new thread because this one is so full of off topic messages! :)

No, I'll give it a try.

Posted by OctavioOlguin on 18-May-2015 15:03

Where did the new post ended?  It promised to be a very rich discussion.....

Posted by Peter Judge on 18-May-2015 15:08

I think it did end :)
 
What are you interested in around errors? We can start again ...
 
 
 
[collapse]
From: OctavioOlguin [mailto:bounce-OctavioOlguin@community.progress.com]
Sent: Monday, 18 May, 2015 16:04
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] Error or Progress.Lang.Error
 
Reply by OctavioOlguin

Where did the new post ended?  It promised to be a very rich discussion.....

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Thomas Mercer-Hursh on 18-May-2015 15:13

No, I think it is all here, just confused by the moving messages.

So, to bring things back, I get Peter's point that using allows one to use a simple name but that this can be undesirable if the simple name is potentially ambiguous without the qualification, e.g., Progress.Lang.Object and System.Object where seeing just Object in the code would require referring back to the top of the problem to know which was which.

So, my question is whether they think Error for Progress.Lang.Error is ambiguous in this way.  AppError and SysError don't seem so, but stylistically I would prefer to treat them all the same.

Posted by OctavioOlguin on 18-May-2015 18:11

What I learned from the error handling handbooks and webcast, i sthat Progress.Lang.Error is just a higher level object, and I should instanteate AppError and SysError, don't I?.

Even for the standards point of view, it calls for better grouping for the source of error, don't you think?

Posted by Laura Stern on 18-May-2015 18:15

Progress.Lang.Error is an interface, not a higher level object.

Posted by OctavioOlguin on 18-May-2015 18:16

And for the direct question of Dr. Thom, I guess that the shortened form of error naming means much more presumptions by original coder about how could a maintainer coder to see the actual code...(sorry my spagethi).

Anway, I say that more structured applying of standards is more solid code, don't you agree?

Posted by OctavioOlguin on 18-May-2015 18:20

sorry, I meant higher in the hierarchy, from the point of view of apperror, and syserror, and yes... absolutelly, an interfase. that's why you recomend to instanteate the app & syserror class, and not directly from .Error... Am I right?

Posted by Laura Stern on 18-May-2015 18:28

Re the interface, you cannot instantiate an interface.  So yes, of course the actual class will be some other type like AppError or SysError.

Re the original question, seems to me you could argue about this with any usage of the USING statement. But I'll let you folk argue about the merits or demerits of that.

Posted by Mike Fechner on 18-May-2015 23:56

You can't create an instance of the SysError. Only the AVM can do that. SysError is reserved for runtime errors, not application errors.

Von meinem Windows Phone gesendet

Von: OctavioOlguin
Gesendet: ‎19.‎05.‎2015 01:12
An: TU.OE.Development@community.progress.com
Betreff: RE: [Technical Users - OE Development] Error or Progress.Lang.Error

Reply by OctavioOlguin

What I learned from the error handling handbooks and webcast, i sthat Progress.Lang.Error is just a higher level object, and I should instanteate AppError and SysError, don't I?.

Even for the standards point of view, it calls for better grouping for the source of error, don't you think?

Stop receiving emails on this subject.

Flag this post as spam/abuse.

Posted by slacroixak on 19-May-2015 02:00

Hi Thomas, Mike, Laura, Peter and all,

For unexpected exceptions that can be either low level ABL errors (Progress.Lang.ProError = plp) or errors of my own App (Progress.Lang.AppError = pla) I like to use the generic interface with a single CATCH Progress.Lang.Error (ple) block, then I use a little utility getErrorMessages() method in a static class (see below). The reason why I do that is I consider I extend the language with my App.  I may use my own App Error objects as well when appropriate, with some extra catch block(s) prior to the last generic ple, but so far, it happens rather rarely

I should not have a problem to handle a SysError with that, should I?

/Sébastien L.

   METHOD PUBLIC STATIC CHARACTER getErrorMessages(ple AS Progress.Lang.Error):

       DEFINE VARIABLE iMaxMsg         AS INTEGER   NO-UNDO.

       DEFINE VARIABLE iMsg            AS INTEGER   NO-UNDO.

       DEFINE VARIABLE cMessageDetails AS CHARACTER NO-UNDO.

       DEFINE VARIABLE pla AS Progress.Lang.AppError NO-UNDO.

       pla = CAST(ple, Progress.Lang.AppError) NO-ERROR.

       iMaxMsg = ple:NumMessages.

       DO iMsg = 1 TO iMaxMsg:

           cMessageDetails = cMessageDetails + "~n" +  ple:GetMessage(iMsg).

       END.

       IF VALID-OBJECT(pla) THEN cMessageDetails = cMessageDetails + "~n" +  pla:ReturnValue.

       RETURN SUBSTRING(cMessageDetails, 2).

   END METHOD.

Posted by Peter Judge on 19-May-2015 07:47

You can catch Progress.Lang.Error and examine the messages for all error types (AppError, SysError and others), and so you can have a single CATCH block. But in order for AppErrors to play nicely with this approach - ie using GetMessage() – you have to specify a message number when instantiating the error. If you don't, the message stack will be empty, ceteris paribus.
 
So RETURN ERROR NEW AppError('my message') has a ReturnValue but no messages.
RETURN ERROR NEW AppError('my message', 0) has one message and no ReturnValue.
 
You can also do something like
oAE = new AppError('my return value')
oAE:AddMessage('message one', 0).     
oAE:AddMessage('message two', 0).     
 
And have both a ReturnValue and error stack.
 
There was a thread on this some time ago (somewhere on Communities or even PSDN) and the result of that was that it is a good idea /best practice to always make sure you're using the error messages  - so RETURN ERROR NEW AppError('my message', 0) – so that you can have simpler catch blocks.
 
There are cases where ReturnValue is unavoidable, but generally you should try to ensure the above.
Foo.p
  RETURN ERROR 'old style error'
 
Bar.p
Run foo.p
Catch e as Error:
   Message e:GetMessage(1).  /* <-- this is empty */
End.
 
Hth,
-- peter
 
[collapse]
From: slacroixak [mailto:bounce-slacroixak@community.progress.com]
Sent: Tuesday, 19 May, 2015 03:01
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] Error or Progress.Lang.Error
 
Reply by slacroixak

Hi Thomas, Mike, Laura, Peter and all,

For unexpected exceptions that can be either low level ABL errors (Progress.Lang.ProError = plp) or errors of my own App (Progress.Lang.AppError = pla) I like to use the generic interface with a single CATCH Progress.Lang.Error (ple) block, then I use a little utility getErrorMessages() method in a static class (see below). The reason why I do that is I consider I extend the language with my App.  I may use my own App Error objects as well when appropriate, with some extra catch block(s) prior to the last generic ple, but so far, it happens rather rarely

I should not have a problem to handle a SysError with that, should I?

/Sébastien L.

   METHOD PUBLIC STATIC CHARACTER getErrorMessages(ple AS Progress.Lang.Error):

       DEFINE VARIABLE iMaxMsg         AS INTEGER   NO-UNDO.

       DEFINE VARIABLE iMsg            AS INTEGER   NO-UNDO.

       DEFINE VARIABLE cMessageDetails AS CHARACTER NO-UNDO.

       DEFINE VARIABLE pla AS Progress.Lang.AppError NO-UNDO.

       pla = CAST(ple, Progress.Lang.AppError) NO-ERROR.

       iMaxMsg = ple:NumMessages.

       DO iMsg = 1 TO iMaxMsg:

           cMessageDetails = cMessageDetails + "~n" +  ple:GetMessage(iMsg).

       END.

       IF VALID-OBJECT(pla) THEN cMessageDetails = cMessageDetails + "~n" +  pla:ReturnValue.

       RETURN SUBSTRING(cMessageDetails, 2).

   END METHOD.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Thomas Mercer-Hursh on 19-May-2015 09:27

The issue is not which of these to use ... they each have their purpose*.   The issue is whether to use fully qualified names when using them or to use a using statement and an unqualified name.

*SysError for system issues, AppError for application issues, and Error as a catchall.

Posted by Mike Fechner on 19-May-2015 09:29

All that noise for a question of style?

Posted by Thomas Mercer-Hursh on 19-May-2015 09:32

I am currently using all three.  AppError to catch things I throw and simply put a message in the log.  SysError also logs  the call stack so I know where it happened.  And, just plain Error is catching things from Proparse that are not caught by the other two.

Posted by Mike Fechner on 19-May-2015 09:35

I personally would catch the errors thrown from proparse using a more specific error type.
Worst case as .NET Exception (System.Exception). But there are more specific error types that proparse.net throws.

Posted by Thomas Mercer-Hursh on 19-May-2015 09:50

Yes, the original question was one of style ... most of the subsequent posts haven't been. :)

Weren't you the one who suggested I do what I am now doing for the Proparse errors?

Posted by Mike Fechner on 19-May-2015 09:53

Maybe I wanted to give you a simpler start into your .NET and error handling adventure.

Posted by Thomas Mercer-Hursh on 19-May-2015 10:05

Further advice welcome.  The catch of Error has allowed us to find some constructs which were not supported including TABLE-SCAN and the use of LIKE in method parameters (yuck), but we are still getting a bunch of Prorefactor.Exception and java.Lang.NullPointerException which seem to be happening in the original parse, i.e., prior to the point where I can track line numbers.  Sometimes we get a call stack; sometimes we don't; but even when we do it isn't pointing at anything clear.  John has a new version that should cover the things we have identified, but it is hard for him to fix something when we don't know what is wrong.

Posted by Mike Fechner on 19-May-2015 10:09

Hijacking your own thread once more ;-)
 
You can catch the prorefactor exception separately – as that only indicates missing syntax in proparse.
You can catch NullPointerException as that indicates, well … a bug in proparse.
 
Missing feature vs. bug. Good reasons for two different error handling strategies and hence two different catch blocks.

Posted by Peter Judge on 19-May-2015 10:11

What's the question you want answered? It's not clear what you're looking for advice on.
 
-- peter
 
[collapse]
From: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
Sent: Tuesday, 19 May, 2015 11:07
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] Error or Progress.Lang.Error
 
Reply by Thomas Mercer-Hursh

Further advice welcome.  The catch of Error has allowed us to find some constructs which were not supported including TABLE-SCAN and the use of LIKE in method parameters (yuck), but we are still getting a bunch of Prorefactor.Exception and java.Lang.NullPointerException which seem to be happening in the original parse, i.e., prior to the point where I can track line numbers.  Sometimes we get a call stack; sometimes we don't; but even when we do it isn't pointing at anything clear.  John has a new version that should cover the things we have identified, but it is hard for him to fix something when we don't know what is wrong.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Thomas Mercer-Hursh on 19-May-2015 10:26

Well, I started the thread on a question of style, whether people thought qualifying or not of error classes was preferable.

Now, we seem to be talking about error handling for .NET.  

Mike, OK, so I could create an catch block for those two errors.  I presume this is just catch blah as class name.  But, can I then do anything different than with the catch on Error?  The problem is getting no information.

Posted by Mike Fechner on 19-May-2015 10:34

If proparse does not give _YOU_ qualified errors, you could give the users of _YOUR_ tool more comfort and tell them why they don’t get their job done:
 

a)      They need to convince someone to add to the syntax of proparse

b)      They need to convince someone to fix a bug deep doen in the guts of proparse

 
I really can’t give you more advice here. I don’t know what you are trying to do.
Von: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
Gesendet: Dienstag, 19. Mai 2015 17:27
An: TU.OE.Development@community.progress.com
Betreff: RE: [Technical Users - OE Development] Error or Progress.Lang.Error
 
Reply by Thomas Mercer-Hursh

Well, I started the thread on a question of style, whether people thought qualifying or not of error classes was preferable.

Now, we seem to be talking about error handling for .NET.  

Mike, OK, so I could create an catch block for those two errors.  I presume this is just catch blah as class name.  But, can I then do anything different than with the catch on Error?  The problem is getting no information.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

Posted by Thomas Mercer-Hursh on 19-May-2015 10:43

John has added to the syntax for the things we know about.  The problem is that we are getting these errors that don't provide a line number or a token, so we don't know what to ask to be added.  Since users of the tool are likely to come to me for help anyway, giving a nicer error message doesn't have a terribly high value ... window dressing, rather than any actual help in solving the problem.

Posted by Mike Fechner on 19-May-2015 10:45

Is this still in any way related to error handling?

Von: Thomas Mercer-Hursh <bounce-tamhas@community.progress.com>
Antworten an: "TU.OE.Development@community.progress.com" <TU.OE.Development@community.progress.com>
Datum: Dienstag, 19. Mai 2015 17:43
An: "TU.OE.Development@community.progress.com" <TU.OE.Development@community.progress.com>
Betreff: RE: [Technical Users - OE Development] Error or Progress.Lang.Error

Reply by Thomas Mercer-Hursh

John has added to the syntax for the things we know about.  The problem is that we are getting these errors that don't provide a line number or a token, so we don't know what to ask to be added.  Since users of the tool are likely to come to me for help anyway, giving a nicer error message doesn't have a terribly high value ... window dressing, rather than any actual help in solving the problem.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

Posted by Thomas Mercer-Hursh on 19-May-2015 10:54

Well, it doesn't have anything to do with the original question ... only Peter has commented on that, really.

It does have to do with error handling if there is anything I could be doing differently that would give me more information about what is happening with Proparse.

Posted by Mike Fechner on 19-May-2015 10:58

I will comment to that in a thread about proparse. 

Posted by Thomas Mercer-Hursh on 19-May-2015 11:12

So, I should start one?

Posted by Thomas Mercer-Hursh on 19-May-2015 11:24
This thread is closed