Candidate for the most helpful error message

Posted by jmls on 02-Aug-2011 11:48

Trying to load some json file into a dataset, and came across this message

**Error parsing JSON: expected brace, but found brace. (15358)

Now, call me stupid, but if you expect something and find that something then there should be no error

All Replies

Posted by Thomas Mercer-Hursh on 02-Aug-2011 12:18

Unless you were expecting a closing brace and found an opening one or vice versa.  Of course, it would be a lot clearer if it said that.

Posted by jmls on 02-Aug-2011 12:26

and is that a missing square open brace, or a closing squiggly brace ?

C'mon - let's find the most useless error message.

On 2 August 2011 18:18, Thomas Mercer-Hursh

Posted by Evan Bleicher on 02-Aug-2011 12:48

This error message is coming out of a third-party library we use.  Development will log a bug report to investigate generating a more helpful message.

Posted by rbf on 02-Aug-2011 13:57

 

**Error parsing JSON: expected brace, but found brace. (15358)


Brilliant!

Posted by jmls on 03-Aug-2011 02:07

Ok, looks like I've got another candidate.

given this code

  catch e as Progress.Lang.ProError :

    message e:NumMessages skip

            view-as alert-box.             

  end catch.

how could it ever possibly display "0" ?

I mean, if there is an error, the count must be > 0 , right ?

So, if there is an error, how do I find out what it is ?

Posted by Admin on 03-Aug-2011 02:11

That's fine! Not every error has messages attached...

UNDO, THROW NEW AppError ("forgive me for not being a message").

Causes an error with NO message.

UNDO, THROW NEW AppError ("forgive me for being a message", 0).

Causes an error with ONE message.

Posted by jmls on 03-Aug-2011 02:14

answering my own question.

undo, throw new AppError(substitute("Cannot find template [&1]",lv_fullTemplate)).

this causes the "problem". I should check either the return-value or change the code to read

undo, throw new AppError(substitute("Cannot find template [&1]",lv_fullTemplate),0).

Posted by jmls on 03-Aug-2011 02:14

damn, sir, you are fast

Posted by Admin on 03-Aug-2011 02:16

So, if there is an error, how do I find out what it is ?

By the other propertiesof the error. Might even ones at you added. Or the type (TYPE-OF).

Welcome to OO error handling

Posted by rbf on 03-Aug-2011 05:08

mikefe wrote:

That's fine! Not every error has messages attached...

UNDO, THROW NEW AppError ("forgive me for not being a message").

Causes an error with NO message.

UNDO, THROW NEW AppError ("forgive me for being a message", 0).

Causes an error with ONE message.

We all walk into this trap sooner or later. The syntax with only one parameter does not do what you expect it to do.

Why is that in the first place?

Posted by Admin on 03-Aug-2011 05:16

Why is that in the first place?

Because nobody paid attention to specs during the 10.1C beta program ...

I tried to get that fixed in the 10.2A beta program, but then 10.1C was already released (for a few days) and than they wouldn't want to change rolled out behavior.

I guess that happens when nobody is paying attention to a beta, because there is a more recent beta program running in parallel.

But the result is much, much more than dangerous.

Posted by Admin on 03-Aug-2011 05:30

That's why I like to have my own Exception (extending AppError) which does not support multiple messages but linking exceptions using the 'cause' exception. I see no point in having more 'messages' for the same exception, I do however throw different kind of exceptions (I do miss the 'throws' option in methods) and if the cause was another exception that will be set as cause of the exception thrown.

Posted by rbf on 03-Aug-2011 05:30

Well I can say for myself that I did quite a bit of testing on structured error handling during the 10.1C beta program but I completely missed this bugger (and me and all of my team members have been bitten by it several times since).

Posted by Admin on 03-Aug-2011 05:41

I do similar

But rather then "Cause" I use InnerException. I know, I am .NET spoiled.

Posted by Admin on 03-Aug-2011 06:45

(and me and all of my team members have been bitten by it several times since).

Everybody get's struck by that every now and then. And error with error-handling are really critical.

I think it's simply poorly designed: The presence of the optional second parameter (the severity - who users that anyway?) should not change the meaning of the first parameter of the same type (CHARACTER).

I guess it was meant for good reasons, so that

RETURN ERROR "ADM-ERROR" .

could simply be replaced with

UNDO, THROW NEW AppError ("ADM-ERROR") .

But the consequences are heavy. I would have suggested an additional startup parameter, to fix this. But as this is soooo critical, I wouldn't want this do depend on a startup parameter.

This thread is closed