Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Do me a favor, would you? Have a quick look at this code and tell me what you think it does...

...

I will admit that it has taken me years, almost two decades really, to fully adopt Clarion error levels in my own coding. 

I'm still doing so a bit grudgingly.

The Clarion help has this to say about error levels, in the context of the ABC ErrorManager object:

Panel

Six Levels of Treatment

By default, the error manager recognizes six different levels of error severity. The default actions for these levels range from no action for benign errors to halting the program for fatal errors. The error manager also supports the intermediate actions of simply notifying the user, or of notifying the user and letting the user decide whether to continue or abort.

Customizable Treatments

These various levels of treatment are implemented with virtual methods so they are easy to customize. The error manager calls a different virtual method for each severity level, so you can override the default error actions with your own application specific error actions. See the various Take methods for examples.

The recognized severity EQUATEs are declared in EQUATES.CLW. These severity levels and their default actions are:

 

Level:Benign (0)

no action, returns Level:Benign

Level:User (1)

displays message, returns Level:Benign or Level:Cancel

Level:Notify (5)

displays message, returns Level:Benign

Level:Fatal (3)

displays message, halts the program

Level:Program (2)

treated as Level:Fatal

Level:Cancel (4)

used to confirm no action taken by User

any other value

treated as Level:Program

 

You may define your own additional severity levels and their associated actions.

 

These values specifically indicate what actions the ErrorManager may take. But there aren't quite as many of them as there may seem to be at first. Level:User appears nowhere in the ABC class library or the templates, other than as a definition. Level:Program is the same as Level:Fatal, and Level:Fatal means exit the program, so it's not something you're likely to use that often.. So that leaves Benign, Notify, and Cancel.

Over the years I've written may procedures and methods that returned a true/false value, and in those circumstances the Clarion error levels seemed overkill. Of the three really usable levels I seem to only need Benign and Notify, to signify True and False 

So why am I switching to the Clarion levels? In part to be more in sync with the ABC classes, and in part because that does leave open the ability to indicate different levels of success or failure. As you can see in the example with local procedures even when there is only one potential return value, although I've mainly done that to make the code line up neatly and not because I suspect I will need a different value at some point. I could just as easily not assign a value to ReturnValue in any of the lines in the Execute statement - the loop will continue as before and will always move beyond those lines where ReturnValue is never assigned.