LPARAMETERS nError, cMethod, nLine * Create an object to store the errors. This.oError = NEWOBJECT("lblError","Handler.VCX") This.oError.Save(m.nError, m.cMethod, m.nLine, This.Name) * When This.oError isn't .NULL., you know an error * has occurred. Check for ISNULL(This.oError). To * reset to no error just say This.oError = .NULL. IF VARTYPE(ThisApp) = "O" This.oError.Populate(ThisApp.ErrorHandler) ThisApp.ErrorHandler.WriteToErrorLog() ENDIF LOCAL ErrMsg ErrMsg = "ErrorNo=" +ALLTRIM(STR(m.nError)) + " " + " in Line = " ; + ALLTRIM(STR(nLine)) + " of " ; + This.Name + " " + PROGRAM(PROGRAM(-1)-2) + " " ; + This.oError.ErrorMessage * This allows me to ignore, or, take a look, but in * a real app, ASSERTS are off. ASSERT .F. MESSAGE m.ErrMsg RETURNThen you can write code like this:
oUseMyTable = NEWOBJECT("UseTable", "Data.VCX") oUseMyTable.Alias = "MyTable" IF oUseMyTable.Open() ELSE * What happened? * Check oUseMyTable.oError ENDIFMany times I have return code that looks like this:
RETURN NOT ISNULL(This.oError)>I think I'm not being clear. Maybe because I'm rather confused by all this myself. :)
>PUBLIC glWasError >ON ERROR glWasError = .T. >USE tablename >ON ERROR >IF glWasError > *-- Use AERROR to get the info and then deal with it >ENDIF >>
>USE tablename >IF ????? && An error occurred > loResult.lSucceded = .F. > loResult.cError = ??????? >ELSE > loResult.lSucceded = .T. >ENDIF > >RETURN loResult >>