changing errorsys

This forum is for general support of Xbase++
Post Reply
Message
Author
bwolfsohn
Posts: 649
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

changing errorsys

#1 Post by bwolfsohn »

We've been using the same errorsys since the last century...

we get a yellow box with many of the details from oError object. But, when it's an operating system error, or index error, it not apparent which database the error occurred in.

i was thinking of adding something like:

IF !empty(alias())
cMessage += ";Alias: "+alias()
ENDIF

but, am very hesitant due to the possibility of endless error looping..

Does anyone see a problem with this addition, or can you suggest an alternative ?
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: changing errorsys

#2 Post by unixkd »

Are you an Express++ user, if yes I can help

Joe.

bwolfsohn
Posts: 649
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: changing errorsys

#3 Post by bwolfsohn »

unixkd wrote:Are you an Express++ user, if yes I can help

Joe.
Joe, I'm a very long time express user, but i don't want to change my entire errorsys... just looking to add the current alias() without crashing ;)
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: changing errorsys

#4 Post by rdonnay »

Brian -

Alias() will never crash the error handler.
I use it in several error handlers that I have written.

Roger
The eXpress train is coming - and it has more cars.

bwolfsohn
Posts: 649
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: changing errorsys

#5 Post by bwolfsohn »

rdonnay wrote:Brian -

Alias() will never crash the error handler.
I use it in several error handlers that I have written.

Roger
That's what i was looking for... many thanks..
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
unixkd
Posts: 579
Joined: Thu Feb 11, 2010 1:39 pm

Re: changing errorsys

#6 Post by unixkd »

#include "xbp.ch"
#include "dcdialog.CH"
#include "error.ch"
//#include "PPCodes.Ch"

GETSETFUNCTION DC_ErrorTrapCrt DEFAULT .f.

FUNCTION PPS_ErrorGui( oError, lDebugWindow )
STATIC soCrt
Local i, cMessage, aOptions, nOption, row, col, cModule, lGui, cInfo, aWaitOn, cCrlf
Local oSession := DBSession(), aMessage := {}

SETDEFAULT lDebugWindow := .f.

cCrlf := IIF(lDebugWindow,Chr(13)+Chr(10),';')

DO CASE
CASE oError:genCode == XPP_ERR_ZERODIV // Division by zero
RETURN 0 // results in 0

CASE oError:genCode == XPP_ERR_NUMERR // Division 0 / 0 ?
IF '/' $ oError:operation .AND. oError:args[1] = 0 .AND. oError:args[2] = 0
RETURN 0
ENDIF

CASE oError:genCode == XPP_ERR_OPEN .AND. ; // Error opening a
oError:osCode == 32 .AND. ; // file on a
oError:canDefault // network

RETURN(.F.)

CASE oError:genCode == XPP_ERR_APPENDLOCK .AND. ;
oError:canDefault // No lock is set

RETURN(.F.)

CASE oError:operation='DbeLoad'
RETURN .t.

CASE ( oError:subCode $ { 4402 } .OR. ;
Upper(oError:operation) $ {'SAVESCREEN'} ) .AND. DC_ErrorTrapCrt()

IF !(Valtype(soCrt) == 'O')
soCrt := DC_CrtWindow()
CLS
ELSE
soCrt:setModalState(XBP_DISP_APPMODAL)
ENDIF
SetAppFocus(soCrt)
SetAppWindow(soCrt)
soCrt:show()
RETURN .f.

ENDCASE

IF IsFunction('DC_WaitOnObject')
aWaitOn := DC_Do('DC_WaitOnObject()')
IF Valtype(aWaitOn) == 'A'
DC_Impl(aWaitOn)
ENDIF
ENDIF

cInfo := ErrorMessage( oError, lDebugWindow ) // Create error message

cMessage := cInfo

aOptions := { "~Break", "~Quit Application", "~Log", "~Edit", "~Inspect" }

IF oError:canRetry
AAdd( aOptions, "Retry" )
ENDIF

IF oError:canDefault
AAdd( aOptions, "Ignore" )
ENDIF

IF ! Empty( oError:osCode )
cMessage += cCrlf + "Operating system error : " + LTrim(Str(oError:osCode))
ENDIF

i := 0
DO WHILE ! Empty( ProcName(++i) ) //.AND. i < 15
IF Trim(ProcName(i)) == '(B)DC_INIT'
LOOP
ENDIF
cMessage+= cCrLf + "Called from " + Trim( ProcName(i) ) + "(" + LTrim( Str( ProcLine(i) ) ) + ")"
Aadd(aMessage, {AllTrim( ProcName(i) ), ProcLine(i) })
ENDDO

cMessage += cCrlf + Repl('-',108)
cMessage += cCrlf + Alias()+Space(10)+"Record No: "+Ntrim(RecNo() )
cMessage += cCrlf + Repl('-',108)

IF lDebugWindow
BREAK
ENDIF

DO WHILE .t.
i := 0
DO WHILE i == 0 // Display ConfirmBox()
DC_ClearEvents()
i := DC_GuiAlert( , cMessage, aOptions , XBPMB_WARNING+XBPMB_APPMODAL+XBPMB_MOVEABLE,"PowerPlus Software Error Message" )
ENDDO

DO CASE
CASE i == 1
Break( oError)
CASE i == 2
EXIT
CASE i == 3
lGui := DC_Gui(.t.)
DC_Log(ProcName(2),ProcLine(2), Strtran(cInfo,';',Chr(13) + Chr(10)) )
DC_Gui(lGui)
CASE i == 4
i := 2
lGui := DC_Gui(.t.)
DO WHILE !Empty(ProcName(i))
cModule := DC_ObjFind(ProcName(i))
IF Empty(cModule)
IF DC_MsgBox(,,{"Can't find source for " + ProcName(i),'Try ' + ProcName(i+1) + '?'},,,,.t.)
i++
LOOP
ENDIF
EXIT
ELSE
DC_EditPrg(cModule+'.PRG',ProcLine(2),'',.t.,.t.,.f.)
EXIT
ENDIF
ENDDO
DC_Gui(lGui)
CASE i == 5
DC_InspectObject(oError)
CASE i == 6 .AND. oError:canRetry // Retry
RETURN .t.
CASE i == 6 .AND. !oError:canRetry // Ignore
RETURN .f.
CASE i == 7 // Ignore
ENDCASE
ENDDO
ErrorLevel(1) // Set error level
IF DbeSetDefault() == "ADSDBE"
AdsApplicationExit()
ElseIf ValType(oSession) == "O"
oSession:disconnect()
EndIf
// UsersLogs(3)
QUIT // End of program
RETURN .F. // The compiler expects a return value
**************************************
STATIC FUNCTION ErrorMessage( oError, lDebugWindow )
LOCAL cMessage := IIf( oError:severity > XPP_ES_WARNING,"Error ", "Warning " ) // Generic error message
LOCAL cCrlf := IIF(lDebugWindow,Chr(13)+Chr(10),';')

IF Valtype( oError:subSystem ) == "C" // Add name of the
cMessage += oError:subSystem // subsystem
ELSE
cMessage += "????" // Unknown subsystem
ENDIF

IF Valtype( oError:subCode ) == "N" // Add error code of
cMessage += "/"+ LTrim(Str(oError:subCode)) // the subsystem
ELSE
cMessage += "/????" // Unknown error code
ENDIF

IF Valtype( oError:description ) == "C" // Add error description
cMessage += cCrlf + "Description : " + oError:description
ENDIF

IF ! Empty( oError:fileName ) // Name of file where
cMessage += cCrlf + "File : " + oError:fileName // the error occured
ELSEIF ! Empty( oError:operation ) // Operation where the error occured
cMessage += cCrlf + "Operation : " + oError:operation
ENDIF
cMessage += cCrlf + "Thread ID : " + LTrim(Str(oError:thread)) // Thread ID where the error occured
//MemoWrit('DCERROR.TXT',cMessage)
RETURN cMessage

Post Reply