On error...
Moderator: Rathinagiri
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
On error...
In HMG, can we have some error catching blocks (like try...catch... in Java) that shall be executed before the application is closed abruptly?
For operations like saving some files, closing the database connections, re-encrypt the decrypted files?
For operations like saving some files, closing the database connections, re-encrypt the decrypted files?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: On error...
That is a question I have asked myself many times.
Is use the clipper command
To log real serious errors.
How do you guys catch errors?
Raumi
Is use the clipper command
Code: Select all
ERRORBLOCK({ |oErr| MyOnError(oErr)})
How do you guys catch errors?
Raumi
Raumi75 http://raumi75.jimdo.com
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: On error...
Hi Rathi and Raumi
Did you tried BEGIN/END SEQUENCE structure ?
Regards
--
Esgici
Did you tried BEGIN/END SEQUENCE structure ?
Regards
--
Esgici
Viva INTERNATIONAL HMG
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: On error...
Nope Esgici. I will try.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: On error...
I use this in IDE to report preview and works perfectly (I've adapted from an old Clipper sample.
Code: Select all
bSaveHandler := errorblock( { |x| break(x) } )
BEGIN SEQUENCE
* This is the code to execute that could fail
EXECUTE REPORT _TempReport PREVIEW
DELETE FILE RePreviewSemaforo.Txt
<...>
RECOVER USING oError
* This is the code to execute if the above code fails
MSGSTOP( oError:Description + " " + oError:Operation , "Report Error:" )
DELETE FILE RePreviewSemaforo.Txt
Exit Program
END
errorblock( bSaveHandler )
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: On error...
A more useful sample is shown in Clipper manual:
Code: Select all
This example demonstrates an error handler returning an error
object to the variable specified in the USING clause of the RECOVER
statement:
LOCAL objLocal, bLastHandler
//
// Save current and set new error handler
bLastHandler := ERRORBLOCK({ |objErr| ;
MyHandler(objErr, .T.) })
//
BEGIN SEQUENCE
.
. <operation that might fail>
.
RECOVER USING objLocal
//
// Send messages to objLocal and handle the error
? "Error: "
IF objLocal:genCode != 0
?? objLocal:description
ENDIF
.
.
.
END
//
// Restore previous error handler
ERRORBLOCK( bLastHandler )
FUNCTION MyHandler( objError, lLocalHandler )
//
// Handle locally returning the error object
IF lLocalHandler
BREAK objError
ENDIF
.
. <other statements to handle the error>
.
RETURN NIL
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: On error...
Thanks Roberto. I will go through and use it.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: On error...
I'm using errorblock and begin/end sequence.
In one of my latest projects I've added sending e-mail with error to me, when something wrong is going on...
In one of my latest projects I've added sending e-mail with error to me, when something wrong is going on...
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: On error...
Hi Rathi
A little (!?) late answer (because just added) : a short compilation about error handling
I hope that will be useful
Regards
--
Esgici
A little (!?) late answer (because just added) : a short compilation about error handling
I hope that will be useful
Regards
--
Esgici
Viva INTERNATIONAL HMG
Re: On error...
Hello all,
This interests me
It would be possible to assemble a complete example to demonstrate this new method using error control and the old ?
Best Regards,
Rossine.
This interests me
It would be possible to assemble a complete example to demonstrate this new method using error control and the old ?
Best Regards,
Rossine.