Hi Gents
I am using TRY CATCH a lot in the app I'm writing.
For example
//Open the Requests table again as a different alias
TRY
WITH OBJECT ::oRequestsCompleteDB := TDbfDataSet():New( )
:oDataSource := AppData:oDataSource
:cProcess := "GENERAL"
:cName := "LLREQUES"
:Alias := "LLCOMPLETE"
:lDisplayErrors := .T.
:lOpen := .T.
:Create()
END
CATCH
::Throw("Failed to open the LLReques.dbf with the Alias LLComplete at:
" + AppData:CapitalPath + AppData:Company)
END
Here's my throw.
//---------------------------------------------------------- --------------------
//Throw a TAppData Exception
//---------------------------------------------------------- --------------------
METHOD Throw( sOperation )
WITH OBJECT ErrorNew()
:Description := "An Exception in an AppData object has occured"
:FileName := "TAppData.prg"
:Operation := sOperation
Eval( ErrorBlock(), HB_QWith() )
END WITH
Return Nil
My throw works, but the problem is that it hides the error.
For example in the code above I have forgetten the c of cAlias. The only way
I can get the run time error is to remove the try catch bloke, then run the
app, see the error, then put it back again. If I don't remove the try catch,
my error handling kicks in and tells me an exception has occured etc.
Any tips on how to stop this happening would be appreciated
Thanks
Nick
In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
TRY/CATCH
-
- Mensajes: 328
- Registrado: Mar Nov 21, 2006 2:10 am