|
FOROS PROFESIONALES WINDEV, WEBDEV y WINDEV Mobile |
| | | | | |
| Inicio → WINDEV 2024 → [WX] - What are the best practices for: Error and Exception Management? |
| [WX] - What are the best practices for: Error and Exception Management? |
| Iniciado por guest, 18,sep. 2017 07:15 - 5 respuestas |
| |
| | | |
|
| |
| Publicado el 18,septiembre 2017 - 07:15 |
Hello,
I am still not able to decide as to how to handle Exceptions programmatically.
As there are many pros here on these forums I would like to know: What are the best practices for: Error and Exception Management?
TIA |
| |
| |
| | | |
|
| | |
| |
| Publicado el 18,septiembre 2017 - 09:13 |
Hi Yogi Yang,
You could take a look at the published WX OO framework I wrote many years ago... There is a more recent one that has some reworked error handling I refactored in V20. I'll see if I can extract it from an old project and post it again.
Error handling: It has an ErrorMessage and ErrorList class that allows you to track error messages in a complete business process flow.
Exception handling: Most methods and functions also have a WHEN EXCEPTION handler that logs (and emails if activated) encountered exceptions.
Cheers,
Peter |
| |
| |
| | | |
|
| | |
| |
| Publicado el 19,septiembre 2017 - 07:45 |
Thanks Peter.
That would be really nice.
Actually I have been a bit confused as to how the hell I should handle errors without crashing my application.
TIA |
| |
| |
| | | |
|
| | |
| |
| Publicado el 19,septiembre 2017 - 08:48 |
Hi YY,
You can already download the original release from the PCSoft repository site.
Bye,
Peter |
| |
| |
| | | |
|
| | |
| |
| Publicado el 19,septiembre 2017 - 11:11 |
Hi, here is a simple explanation on how we do it:
1 - We NEVER do any kind of DIRECT (CRUD) Add, Read, Modify or Delete in the UI (Windows or Pages). 2 - All CRUDs are done in procedures, inside a TRANSACTION frame and always return a TRUE/FALSE and (maybe) an error. 3. We check the Automatic management of errors and exceptions for EVERY procedure and add code at the end (see the example). 4. CRUD procedures always come in pairs - one handles the transaction and the other the CRUD functionality. 5. We never use WHEN EXCEPTION IN etc inside the CRUD procedures.
Here are SIMPLE procedures (Business Process) for Deleting a record from a file called Dummy in a C/S HFSQL environment:
///////////////////////////////////////////////////////////////////////////////// Procedure DeleteDummy (LOCAL p_sPrimaryKey is string, p_sErrorMessage is string) HOnError("*",hErrAll,"") p_sErrorMessage=""
IF HTransactionStart(myConnection)=False THEN p_sErrorMessage="problem Starting the C/S transaction ..." RESULT False END
IF DeleteDummy_private(p_sPrimaryKey, p_sErrorMessage)=False // Cancel the transaction ... IF HTransactionCancel(myConnection)=False THEN // very nasty problem - should never happen // So end the Program and LET the C/S Engine handle it automatically EndProgram() END END
// Validate the transaction IF HTransactionEnd(myConnection)=False THEN // very nasty problem - should never happen // So end the Program and LET the C/S Engine handle it automatically EndProgram() END
RESULT True
// take care of exceptions and other errors CASE ERROR: p_sErrorMessage="HFSQL error: " + HError() RESULT False
CASE EXCEPTION: p_sErrorMessage="Exception:"+ExceptionInfo(errCode) RESULT False
////////////////////////////////////////////////////////////////////////////////////////////
Procedure DeleteDummy_private (LOCAL p_sPrimaryKey is string, p_sErrorMessage is string)
IF HReadSeekFirst(Dummy,sDummyPK,p_sPrimaryKey =False THEN p_sErrorMessage="Record not found" RESULT False END
HDelete(Dummy) IF ErrorOccurred THEN IF HErrorIntegrity() THEN p_sErrorMessage="Integrity Issue" RESULT False ELSE p_sErrorMessage="HFSQL error: " + HError() RESULT False END END
RESULT True // take care of exceptions and other errors CASE ERROR: p_sErrorMessage="HFSQL error: " + HError() RESULT False
CASE EXCEPTION: p_sErrorMessage="Exception:"+ExceptionInfo(errCode) RESULT False
////////////////////////////////////////////////////// Steven Sitas www.alpha360.biz |
| |
| |
| | | |
|
| | |
| |
| Publicado el 01,abril 2018 - 12:21 |
| Peter, kan ik die update ook krijgen? Ben je nog van plan updates uit te voeren of is dit WX project slapende? |
| |
| |
| | | |
|
| | | | |
| | |
| | |
| |
|
|
|