/* * $Id$ */ /*** * * Errorsys.prg * * Standard Clipper error handler * * Copyright (c) 1990-1993, Computer Associates International, Inc. * All rights reserved. * * Compile: /m /n /w * */ /* * Harbour Project source code: * HTML output conversion * * Copyright 2000 Manos Aspradakis * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version, with one exception: * * The exception is that if you link the Harbour Runtime Library (HRL) * and/or the Harbour Virtual Machine (HVM) with other files to produce * an executable, this does not by itself cause the resulting executable * to be covered by the GNU General Public License. Your use of that * executable is in no way restricted on account of linking the HRL * and/or HVM code into it. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit * their web site at http://www.gnu.org/). * */ /* * The following parts are Copyright of the individual authors. * www - http://www.harbour-project.org * * Copyright 2000 Luiz Rafael Culik * Porting this library to Harbour * * See doc/license.txt for licensing terms. * */ #include "default.ch" #include "error.ch" #define DEF_ERR_HEADER "Date : "+DTOC(Date())+"
"+; "Time : "+Time()+"
" // put messages to STDERR #command ? => ?? Chr(13) + Chr(10) ; ?? #command ?? => OutErr() // used below #xTranslate NTRIM() => ALLTrim( Str( ) ) REQUEST HARDCR REQUEST MEMOWRIT STATIC sbFixCorrupt STATIC scErrFooter := " " /*** * ErrorSys() * * Note: automatically executes at startup */ //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ PROC ErrorSys() //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ErrorBlock( {|e| DefError(e)} ) return /*** * DefError() */ //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ STATIC FUNC DefError(e) //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ local i, cMessage:= "" Local cErrString := "" LOCAL nDispCount := DispCount() Local aError := {} LOCAL nH := IF( PageHandle() == NIL, 0, PageHandle() ) // by default, division by zero yields zero IF ( e:genCode == EG_ZERODIV ) return (0) END IF ( e:genCode == EG_CORRUPTION ) if valtype(sbFixCorrupt) == "B" EVAL( sbFixCorrupt, e ) RETURN .F. ELSE RETURN .F. ENDIF ENDIF // for network open error, set NETERR() and subsystem default IF ( e:genCode == EG_OPEN .and. (e:osCode == 32 .OR. e:osCode == 5); .and. e:canDefault ) NETERR(.T.) RETURN (.F.) // NOTE END // for lock error during APPEND BLANK, set NETERR() and subsystem default IF ( e:genCode == EG_APPENDLOCK .and. e:canDefault ) NETERR(.T.) RETURN (.F.) // NOTE END // build error message cMessage += ErrorMessage(e) // display message and traceback IF ( !Empty(e:osCode) ) cMessage += " (DOS Error : " + NTRIM(e:osCode) + ")" END // RESET System // cErrString := CRLF()+""+CRLF() cErrString += '' cErrString += '" cErrString += '" cErrString += '' cErrString += '' cErrString += '"+CRLF()+""+CRLF()+"
' cErrstring += ''+CRLF() cErrString += "ERROR REPORT" cErrString += "
' cErrstring += ''+CRLF() cErrString += DEF_ERR_HEADER cErrString += "
' cErrstring += ''+CRLF() cErrString += ''+cMessage+'' cErrString += '
'+CRLF() cErrstring += ''+CRLF() cErrString += "ERRORCODE...... :"+ NTRIM(e:GenCode)+"
"+CRLF() cErrString += "SUBSYSTEM..... :"+ e:SubSystem +"
"+CRLF() cErrString += "DESCRIPTION...:"+ e:Description +"
"+CRLF() cErrString += "OPERATION......:"+ e:Operation +"
"+CRLF() cErrString += "FILENAME........ :"+ e:FileName +"
"+CRLF() cErrString += "TRIES............. :"+ NTRIM(e:Tries)+CRLF() cErrString += '
' cErrstring += ''+CRLF() cErrstring += '' i := 2 while ( !Empty(ProcName(i)) ) cErrString += "Called from "+ Trim(ProcName(i)) + ; "(" + NTRIM(ProcLine(i)) + ")
" + CRLF() i++ END cErrstring += '
' cErrString += '
' cErrstring += ''+CRLF() cErrstring += "Extra Notes..." cErrString += "
"+CRLF() FWrite( nH, "
"+cErrString+CRLF() ) //ÄÄÄÄÄÄÄÄ Write/Append Error Log MemoWrit( "Error.Log", HARDCR(cErrString)+CRLF()+; HARDCR( MEMOREAD("Error.Log") ) ) FWrite( nH, ""+CRLF()+""+CRLF()+""+CRLF() ) /* FWrite( nH, "
"+CRLF() ) FWrite( nH, "]+CRLF() ) FWrite( nH, "
"+CRLF() ) FWrite( nH, ["+CRLF()+""+CRLF() ) CLOSE ALL // give up ErrorLevel(1) QUIT RETURN(.F.) //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ FUNCTION SetCorruptFunc( bFunc ) //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ if valtype( bFunc ) == "B" sbFixCorrupt := bFunc ENDIF RETURN sbFixCorrupt FUNCTION SetErrorFooter() RETURN( scErrFooter ) /*** * ErrorMessage() */ //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ STATIC FUNC ErrorMessage(e) //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ local cMessage :="" // start error message cMessage += if( e:severity > ES_WARNING, "Error ", "Warning " ) // add subsystem name if available IF ( ValType(e:subsystem) == "C" ) cMessage += e:subsystem() ELSE cMessage += "???" END // add subsystem's error code if available if ( ValType(e:subCode) == "N" ) cMessage += ("/" + NTRIM(e:subCode)) ELSE cMessage += "/???" END // add error description if available if ( ValType(e:description) == "C" ) cMessage += ("
" + e:description) END // add either filename or operation if ( !Empty(e:filename) ) cMessage += (": " + e:filename) ELSEIF ( !Empty(e:operation) ) cMessage += (": " + e:operation) END cMessage += CRLF() return (cMessage)