Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
11
Erster Beitrag:
vor 7 Monaten, 3 Wochen
Letzter Beitrag:
vor 7 Monaten, 2 Wochen
Beteiligte Autoren:
John Fligg, Fabrice Harari, Steven Sitas, Piet van Zanten

So confused about error checking

Startbeitrag von John Fligg am 25.11.2017 10:50

For about a year on and off I have been trying to get a global error checking procedure to work. This week I attacked it with a vengeance only to be knocked down again.

In the Global Init of my app I have:

GLOBAL

//General error processing
WHEN EXCEPTION
ErrorHandling()
END

ErrorHandling() is a procedure that sends out an email but it is never called.

My latest test while debugging I get:

ErrorInfo = Duplicates found for key on file.

The Exception code is not called. Why not? What on earth am I doing wrong.

BTW this is an AWP site if that makes any difference.

Many thanks in advance.

Antworten:

Hi John,

Hyperfile errors have separate error handling, you need HOnError() to control the handling.
I use HOnError("*",hErrAll,"") to handle each error individually.
Then you need hErrorDuplicates() and hErrorIntegrity() for each hAdd an hModify call.

Kind regards,
Piet

von Piet van Zanten - am 25.11.2017 11:14
I see. I knew I was missing something fundamental.

Thx

John

von John Fligg - am 25.11.2017 11:23
Hi John

to complete the previous answer : EVERYTHING has a normal error handling, managed either with hErrorinfo or ErrorInfo
Exceptions are catching crashes, ie error not 'normal'/not managed inside each function.

By example, if you use a fxxx function top manage files on disk, and you try to access an incorrect folder (does not existe, rights problems, etc), you will get an error, managed at the function level (ie the function will return -1, and you need to use errorinfo to manage it.)...

Exceptions are therefore ...the exceptions to the rules, ie errors not managed at the local function level, because nobody ever though this could happen :-)

As a result, you HAVE to test the result of each function, all the time -AND- use exception to manage the unexpected.

Best regards

von Fabrice Harari - am 25.11.2017 12:07
Thank you Fabrice. I now understand it.

Thankfully I have a single procedure that assigns a GUID with date/time stamp and allows for Add/Modify or Delete. So when ready to do something with a record I just call the routine with the filename and AM or D and use indirection in the routine. That means I can put the appropriate error checks in there just once.

Incidentally reading the Help on this there is no need to check for anything on HAdd etc. as the automatic error handling does it all.

So in my Init code I have the following which seems to be working when I force an error:

//General error processing
WHEN EXCEPTION
OnExceptionError()
END

//Trap HF and other errors

HOnError("*",hErrLock, "OnLockError")
HOnError("*", hErrIntegrity + hErrDuplicates + hErrModify + hErrPassword, "OnOtherError")

von John Fligg - am 25.11.2017 15:58
Hi John,

>>Incidentally reading the Help on this there is no need to check for anything on HAdd etc. as the automatic error handling does it all.

von Fabrice Harari - am 26.11.2017 13:43
Grr just when I thought I had a handle on it all.

So how exactly is it done? Does this go in the Global Init?

WHEN EXCEPTION
OnExceptionError()
END

//Trap HF and other errors
HOnError("*", hErrAll, "OnGeneralError")

So what do I add after each HAdd, Modify etc?

Back to confusion

Thx

von John Fligg - am 26.11.2017 16:16
Hi John,
you can take a look at our alpha360 project and see how we do it.
You can find the Open Source version at:
www.alpha360.biz

Regards
Steven Sitas

von Steven Sitas - am 27.11.2017 08:32
Thank you Steven.

von John Fligg - am 27.11.2017 08:38
Hmm Steven and Fabrice. Please don't think I am saying you are wrong as I see your points perfectly.

Having done what Steven does I get exactly the same results using a global trap of errors. I appreciate you get a specific message but even using a Global method you can still get a unique message.

In my case I simply tell the User an error has occurred and either tell them to try again or if it's fatal stop.

In my Program error trap procedure I just check for each individual error code using Case and I can then provide a specific message. However I do not allow the user to interfere in any way (other than trying again) and send the email to me silently.

Thanks for the input all the same but I feel that having error trapping code on every window and procedure is a bit unmanageable.

Thx

John

von John Fligg - am 27.11.2017 09:53
Hi John,
if you have a TRANSACTION in every procedure, like we do, I think you must have error trapping (or error handling) code at the procedure(transaction) level.

Regards
Steven Sitas

von Steven Sitas - am 27.11.2017 14:52
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.