f



When using "error" should the error message and error information be the same?

I wrote a Tcl package for a proprietary product which makes heavy
usage of the "error" command. To this time when I return an error I
use the command

set errMsg "An Error Message"
error $errMsg $errMsg

I was wondering if maybe I was using the arguments incorrectly here or
if in reality there is no real difference between the two other than
when it is available to the user (along with the returned stack when
using $errorInfo).
0
7/26/2009 4:03:05 AM
comp.lang.tcl 23428 articles. 2 followers. Post Follow

3 Replies
1943 Views

Similar Articles

[PageSpeed] 0

Eddie Borjas wrote:
> I wrote a Tcl package for a proprietary product which makes heavy
> usage of the "error" command. To this time when I return an error I
> use the command
> 
> set errMsg "An Error Message"
> error $errMsg $errMsg
> 
> I was wondering if maybe I was using the arguments incorrectly here or
> if in reality there is no real difference between the two other than
> when it is available to the user (along with the returned stack when
> using $errorInfo).

First off, consider using the newer [return -error] construct instead of 
[error].

Now to answer your question, IMHO no they should not be the same.  The 
return value should be a nice user level error message.  The errorInfo part 
should also be human readable, but aimed at a programmer.

Lastly, IMHO you should always be giving the errorCode value, which should 
be a list that is designed to be more "program" friendly.

-- 
+------------------------------------------------------------------------+
| Gerald W. Lester                                                       |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
0
Gerald.Lester (2014)
7/26/2009 4:25:21 AM
On 26 July, 05:25, "Gerald W. Lester" <Gerald.Les...@cox.net> wrote:
> Now to answer your question, IMHO no they should not be the same. =A0The
> return value should be a nice user level error message. =A0The errorInfo =
part
> should also be human readable, but aimed at a programmer.
>
> Lastly, IMHO you should always be giving the errorCode value, which shoul=
d
> be a list that is designed to be more "program" friendly.

The way I think about it is that the message is the part that you
would localize for the end user, the errorInfo is the part that you
send in the bug report, and the errorCode is what your program uses to
figure out if this is an expected error that shouldn't be reported at
all.

Donal.
0
7/26/2009 11:48:42 AM
Gerald W. Lester wrote:
[...]
> First off, consider using the newer [return -error] construct instead of 
> [error].

Only in certain situations. For most errors in application code, [error] 
is exactly what you want to use (or [throw] in 8.6), as it gives the 
most precise stack trace. With [return -code error] you lose information 
about exactly where in the procedure the error was thrown. The main use 
of [return -code error] is when you are writing library code/custom 
control structures, in which case it is useful to remove the control 
structure internals from the stack trace.

-- Neil
0
nem3909 (1000)
7/28/2009 10:56:35 AM
Reply: