PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WD20] Global Exception Processing
[WD20] Global Exception Processing
Débuté par David Egan, 01 déc. 2015 06:54 - 2 réponses
Posté le 01 décembre 2015 - 06:54
Hi
I have a small component in which I want to set my own exception handling, no matter where it occurs. I have therefore put a WHEN EXCEPTION clause in the project initialisation code. For testing purposes I have added ExceptionThrow(1) to one of the global procedures. This throws the exception but I still get the stock standard exception message which in turn kicks me right out of the program which is using the component.

However if I throw the exception within a window procedure (even if I have a separate WHEN EXCEPTION within the window init code) it uses the project exception handling. I'm confused! This seems to be back to front to what the help says & what I would logically expect, (but it suits me for present purposes as I only put exception handling in the window to try & work out what is going on).

I don't know if I'm missing something here but I've always had problems getting general exceptions to work; the scope always seems to be different to what I expect!. Is my understanding wrong, or am I doing something wrong? Most importantly how can I get my project exception clause to work for global procedures?

Thanks

David
Posté le 01 décembre 2015 - 11:52
Hi David,

you are clearly adding a level of complexity with the component.

Did you try to add a second when exception in the MAIN PROJECT init code?

I suspect that the VISIBILITY of the objects of the component MAY have an incidence. So if a coponent window is exposed to the main project, it's part of the main project ad exception are managed there, while a window used internally by the component would be managed from the component init code.

I haven't tested this at all, but it would make sense to me if it worked that way

Best regards
Posté le 02 décembre 2015 - 13:46
Hi,

Some considerations:
1) Exceptions are treated hierarchically (first encapsulated code, then Windows defined exception, then project initialization)
2) Regarding to components, there is a slight diference: The project initialization exception treatment of the component is never used (it is used the project initialization of the caller project).

So, I advise you to:
1) Define WHEN... EXCEPTION inside of the global procedure code (if appropriated)
2) Consider that the project initialization exception treatment also fires non treated component exceptions.

Hope it helps,

Bruno