Enhance errorsys.prg
- Marc Venken
- Posts: 1485
- Joined: Tue Jun 14, 2016 7:51 am
- Location: Belgium
Enhance errorsys.prg
I get a runtime error like this
Time from start: 0 hours 0 mins 23 secs
Error occurred at: 29/11/2021, 10:58:19
Error description: Error DBFNTX/1056 Open error: c:\marc\FACTFIVE
Stack Calls
===========
Called from: => DBUSEAREA( 0 )
Called from: .\maveco.PRG => DBFFPT( 4873 )
Called from: .\maveco.PRG => (b)BUILDMENU( 517 )
I want this error to have a better solution to close the program, but it is standard FW
How can I use FW errorsys.prg and trap the errors that are not insite the errorsys.prg. Can I call a extra function for the missing errors ?
Time from start: 0 hours 0 mins 23 secs
Error occurred at: 29/11/2021, 10:58:19
Error description: Error DBFNTX/1056 Open error: c:\marc\FACTFIVE
Stack Calls
===========
Called from: => DBUSEAREA( 0 )
Called from: .\maveco.PRG => DBFFPT( 4873 )
Called from: .\maveco.PRG => (b)BUILDMENU( 517 )
I want this error to have a better solution to close the program, but it is standard FW
How can I use FW errorsys.prg and trap the errors that are not insite the errorsys.prg. Can I call a extra function for the missing errors ?
Marc Venken
Using: FWH 23.08 with Harbour
Using: FWH 23.08 with Harbour
- Marc Venken
- Posts: 1485
- Joined: Tue Jun 14, 2016 7:51 am
- Location: Belgium
Re: Enhance errorsys.prg
Found it I think
I can trap all e:SubCode errors that are not supported with FW-error, but FW-Errorsystem is still working right ?
what is this doing ? : return Eval( bOldErrHandler, e )
Should I close all files, end object, fonts,.... etc and then stop the program with a screen like : Please Restart te program !
I can trap all e:SubCode errors that are not supported with FW-error, but FW-Errorsystem is still working right ?
what is this doing ? : return Eval( bOldErrHandler, e )
Should I close all files, end object, fonts,.... etc and then stop the program with a screen like : Please Restart te program !
Code: Select all | Expand
// Set this at the start of the main module
ErrorBlock( { |e| MyErrorHandler( e, bOldErr ) } )
function MyErrorHandler( e, bOldErrHandler )
if e:SubCode == 1021
MsgAlert( e:Description + CRLF + ;
"FIELD : " + e:Operation + CRLF + ;
ProcName( 2 ) + CRLF + ;
"Line : " + LTrim( Str( ProcLine( 2 ) ) ) )
// Decide what the programmer wants to do here
return .f.
endif
if e:SubCode == 1056
xbrowser(e)
MsgAlert( "Errorcode : "+ e:Subcode+ CRLF+ ;
"Errorname : "+e:Description + CRLF + ;
"FILE : " + e:filename + CRLF + ;
ProcName( 2 ) + CRLF + ;
"Line : " + LTrim( Str( ProcLine( 2 ) ) ) )
// Decide what the programmer wants to do here
return .f.
endif
return Eval( bOldErrHandler, e )
Marc Venken
Using: FWH 23.08 with Harbour
Using: FWH 23.08 with Harbour
- karinha
- Posts: 7951
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Enhance errorsys.prg
I do not think so. Ideally, when you break the program, you create an option for the user to send you an email with the ERROR.LOG for your support to fix the program. I do like this
Regards, saludos.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7951
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Enhance errorsys.prg
Look, use the google translator, please.
Regards, saludos.
Code: Select all | Expand
#include "error.ch"
#include "FiveWin.ch"
external _fwGenError // Link FiveWin generic Error Objects Generator
#define NTRIM(n) ( LTrim( Str( n ) ) )
#define DLG_TITLE "FiveWin for xHarbour"
#command QUIT => ( PostQuitMessage( 0 ), __Quit() )
//----------------------------------------------------------------------------//
static bUserAction, bUserDlg
STATIC lEnviouErroLog := .F.
//----------------------------------------------------------------------------//
// Note: automatically executes at startup
proc ErrorSys()
ErrorBlock( { | e | ErrorDialog( e ) } )
return
//----------------------------------------------------------------------------//
procedure ErrorLink()
return
function SetErrorPath( cPath )
local cOldPath
static cErrorPath := ".\"
cOldPath = cErrorPath
if PCount() == 1 .and. ValType( cPath ) == "C"
cErrorPath = cPath
endif
return cOldPath
function SetErrorFileName( cFileName )
local cOldFileName
static cErrorFileName := "error.log"
cOldFileName = cErrorFileName
if PCount() == 1 .and. ValType( cFileName ) == "C"
cErrorFileName = cFileName
endif
return cOldFileName
function SetErrorDialog( bDialog )
local bOldDlg := bUserDlg
if PCount() == 1 .and. ValType( bDialog ) == "B"
bUserDlg := bDialog
endif
return bOldDlg
function SetPostErrorAction( bAction )
local bPrevious := bUserAction
if ValType( bAction ) == 'B'
bUserAction := bAction
endif
return bPrevious
//----------------------------------------------------------------------------//
static function ErrorDialog( e ) // -> logical or quits App.
local oDlg, oLbx, oFont
local lRet // if lRet == nil -> default action: QUIT
local n, j, cMessage, aStack := {}
local oSay, hLogo
local nButtons := 1
local cErrorLog := ""
local aVersions := GetVersion()
local aTasks
local aRDDs, nTarget, uValue
local oOldError
local cRelation
local lIsWinNT := IsWinNT()
local nLeftQ
local nLeftR := 0
local nLeftD
local nTopBtn := 137, nBtnW := 30, nBtnH := 11
local nDlgW := 450, nDlgH := 300
local nTopLbx := 33, nLbxW := 220, nLbxH
LOCAL oEmail, cMemoAtual, oGetMail
LOCAL nSpaceDisk, lsucesso := .F.
LOCAL oPrn, cError, nLin, nLinha
LOCAL cSeqErro, cAlias
PUBLIC cVersaoNota
// EM: 26/11/2019 - Joao.
cMemoAtual := Trans( Int( nExtMem() / ( 1024 * 1024 * 1024 ) + 1 ), "@E 999.99 GB Free" ) + ;
" -> EM WINDOWS DE 64 BITS, MINIMO: 8 GBs DE RAM." +CRLF+ ;
" SE VOCE TEM MENOS DE 8 GBS, PROVIDENCIE NOVOS PENTES DE MEMORIA." +CRLF+ ;
" SE O SEU WINDOWS FOR DE 64 BITS. WINDOWS DE 32 BITS, MINIMO: 4 GBS DE RAM."
if lIsWinNT
nDlgH += 50
endif
nTopBtn = Int( nDlgH / 2 ) - nBtnH - 6
nLbxH = nTopBtn - nTopLbx - 2
// by default, division by zero yields zero
if ( e:genCode == EG_ZERODIV )
return 0
end
// 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. // Warning: Exiting!
end
// for lock error during APPEND BLANK, set NETERR() and subsystem default
if ( e:genCode == EG_APPENDLOCK .and. e:canDefault )
NetErr( .t. )
return .f. // OJO SALIDA
endif
if Left( ProcName( 7 ), 10 ) == "ERRORDIALO"
SET RESOURCES TO
ErrorLevel( 1 )
QUIT
endif
// Incluido em 09/09/2019 By Joao Santos
IF UPPER(e:Description)="CORRUPTION DETECTED" .OR. ;
UPPER(e:Description)="DETECTADO ÖNDICE CORROMPIDO" .OR. ;
UPPER(e:Description)="DETECTADO INDICE CORROMPIDO"
MsgInfo( OemToAnsi( "ATEN€ÇO USUµRIO: " )+CRLF+ ;
OemToAnsi( "O PROGRAMA DE OR€AMENTOS EXTRAS, " )+CRLF+ ;
OemToAnsi( "DETECTOU QUE UM DOS INDICES DA µREA, " )+CRLF+ ;
OemToAnsi( "ESTµ CORROMPIDO(CORRUP€ÇO). " )+CRLF+ ;
OemToAnsi( "DESCRIۂO: " + UPPER(e:Description) )+CRLF+ ;
OemToAnsi( "ÖNDICE........: " + LEFT(RIGHT(e:FileName,12),8)+".CDX" )+CRLF+ ;
OemToAnsi( "TECLE <ENTER> PARA CONTINUAR... " ), ;
OemToAnsi( "Banco de Dados Corrupidos. Reindexar." ) )
ENDIF
cErrorLog += "Application - Leia o Erro. Favor Enviar ao Suporte." + CRLF
cErrorLog += "===========" + CRLF
cErrorLog += " Path and name: " + GetModuleFileName( GetInstance() )
#ifdef __CLIPPER__
cErrorLog += " (16 bits)" + CRLF
#else
cErrorLog += If( IsWin64()," (64 bits)", " (32 bits)" ) + CRLF
#endif
// 11.960.320
cErrorLog += " Size: " + Transform( FSize( GetModuleFileName( ;
GetInstance() ) ), "99,999,999 bytes" ) + CRLF
#ifdef __CLIPPER__
cErrorLog += " Max files handles permited: ( SetHandleCount() ) " + ;
Str( SetHandleCount(), 3 ) + CRLF
#endif
cErrorLog += " Compiler version: " + Version() + CRLF
// cErrorLog += " FiveWin version: " + FWVERSION + CRLF
cErrorLog += " C compiler version: " + hb_Compiler() + CRLF
#ifdef __CLIPPER__
cErrorLog += " Windows and MsDos versions: " + ;
AllTrim( Str( aVersions[ 1 ] ) ) + "." + ;
AllTrim( Str( aVersions[ 2 ] ) ) + ", " + ;
AllTrim( Str( aVersions[ 3 ] ) ) + "." + ;
AllTrim( Str( aVersions[ 4 ] ) ) + CRLF + CRLF
#else
cErrorLog += " Windows version: " + ;
AllTrim( Str( aVersions[ 1 ] ) ) + "." + ;
AllTrim( Str( aVersions[ 2 ] ) ) + ", Build " + ;
AllTrim( Str( aVersions[ 3 ] ) ) + ;
" " + aVersions[ 5 ] + CRLF + CRLF
#endif
// Preciso saber qual a memoria da maquina da Lucia - 26/11/2019 Joao.
cErrorLog += " Memoria Disponivel: " + cMemoAtual + CRLF + CRLF
cErrorLog += " Versão: " + cVersaoNota +CRLF
cErrorLog += " Sistema Operacional: " + OS() +" - "+ Iif( IsWin64()," (64 bits)", " (32 bits)" ) + CRLF
cErrorLog += " Time from start: " + TimeFromStart() + CRLF
cErrorLog += " Error occurred at: " + ;
DToC( Date() ) + ", " + Time() + CRLF
// Error object analysis
cMessage = " Error description: " + ErrorMessage( e ) + CRLF
cErrorLog += cMessage
IF .NOT. EMPTY( e:osCode ) // INCLUIDO EM: 22/04/2021 - Joao
// ? DOSErro( e:osCode ) // mostra a falha +- linha: 788
MsgStop( OemtoAnsi( "ATEN€ÇO USUµRIO, ISTO UM AVISO: " )+CRLF+ ;
OemtoAnsi( "NÇO ERRO DE PROGRAMA, DE REDE." )+CRLF+CRLF+ ;
( UPPER( cMessage ) )+CRLF+CRLF+ ;
( DOSErro( e:osCode ) )+CRLF+CRLF+ ;
OemToAnsi( "PROBLEMAS NA REDE DE COMPUTADORES." )+CRLF+ ;
OemToAnsi( "RETIRE TODOS OS USUµRIOS DA REDE: " )+CRLF+ ;
OemToAnsi( "DESLIGUE O SEU COMPUTADOR... " )+CRLF+ ;
OemToAnsi( "DESLIGUE O SERVIDOR DE ARQUIVOS..." )+CRLF+ ;
OemToAnsi( "RELIGUE O SERVIDOR DE ARQUIVOS..." )+CRLF+ ;
OemToAnsi( "RELIGUE O SEU COMPUTADOR... " )+CRLF+ ;
OemToAnsi( "PERSISTINDO O ERRO, CHAME O SEU " )+CRLF+ ;
OemToAnsi( "TCNICO DE COMPUTADORES. " )+CRLF+ ;
OemToAnsi( "ESTE NÇO UM ERRO DE PROGRAMA. " )+CRLF+ ;
OemToAnsi( "CHAME SEU TCNICO DE REDE URGENTE." )+CRLF+ ;
OemToAnsi( "VERSÇO: " + cVersaoNota )+CRLF+ ;
OemToAnsi( "TECLE <ENTER> PARA CONTINUAR... " ), ;
OemToAnsi( "ERRO DE REDE OU NO SEU COMPUTADOR, CHAME TCNICO" ) )
cErroRede := "http://pt.kioskea.net/faq/7012-codigos-de-erros-do-windows-parte-1"
// ShellExecute(GetActiveWindow(),"open",'"'+cErroRede+'"', 0)
ENDIF
if ValType( e:Args ) == "A"
cErrorLog += " Args:" + CRLF
for n = 1 to Len( e:Args )
cErrorLog += " [" + Str( n, 4 ) + "] = " + ValType( e:Args[ n ] ) + ;
" " + cValToChar( cValToChar( e:Args[ n ] ) ) + ;
If( ValType( e:Args[ n ] ) == "A", " length: " + ;
AllTrim( Str( Len( e:Args[ n ] ) ) ), "" ) + CRLF
next
endif
cErrorLog += CRLF + "Stack Calls" + CRLF
cErrorLog += "===========" + CRLF
n := 2 // we don't disscard any info again !
while ( n < 74 )
if ! Empty(ProcName( n ) )
AAdd( aStack, " Called from: " + ProcFile( n ) + " => " + Trim( ProcName( n ) ) + ;
"( " + NTRIM( ProcLine( n ) ) + " )" )
cErrorLog += ATail( aStack ) + CRLF
endif
n++
end
cErrorLog += CRLF + "System" + CRLF
cErrorLog += "======" + CRLF
#ifdef __CLIPPER__
cErrorLog += " CPU type: " + GetCPU() + CRLF
#else
if ! IsExe64()
cErrorLog += " CPU type: " + GetCPU() + " " + ;
AllTrim( Str( GetCPUSpeed() ) ) + " Mhz" + CRLF
endif
#endif
cErrorLog += " Hardware memory: " + ;
cValToChar( Int( nExtMem() / ( 1024 * 1024 ) ) + 1 ) + ;
" megs" + CRLF + CRLF
cErrorLog += " Free System resources: " + AllTrim( Str( GetFreeSystemResources( 0 ) ) ) + " %" + CRLF + ;
" GDI resources: " + AllTrim( Str( GetFreeSystemResources( 1 ) ) ) + " %" + CRLF + ;
" User resources: " + AllTrim( Str( GetFreeSystemResources( 2 ) ) ) + " %" + CRLF + CRLF
aTasks = GetTasks()
cErrorLog += " Windows total applications running: " + ;
AllTrim( Str( Len( aTasks ) ) ) + CRLF
for n = 1 to Len( aTasks )
cErrorLog += " " + Str( n, 3 ) + " " + aTasks[ n ] + CRLF
next
// Warning!!! Keep here this code !!! Or we will be consuming GDI as
// we don't generate the error but we were generating the bitmap
hLogo = FWLogoBitMap()
if e:canRetry
nButtons++
endif
if e:canDefault
nButtons++
endif
cErrorLog += CRLF + "Variables in use" + CRLF + "================" + CRLF
cErrorLog += " Procedure Type Value" + CRLF
cErrorLog += " ==========================" + CRLF
n := 2 // we don't disscard any info again !
while ( n < 74 )
if ! Empty( ProcName( n ) )
cErrorLog += " " + Trim( ProcName( n ) ) + CRLF
for j = 1 to ParamCount( n )
cErrorLog += " Param " + Str( j, 3 ) + ": " + ;
ValType( GetParam( n, j ) ) + ;
" " + cGetInfo( GetParam( n, j ) ) + CRLF
next
for j = 1 to LocalCount( n )
cErrorLog += " Local " + Str( j, 3 ) + ": " + ;
ValType( GetLocal( n, j ) ) + ;
" " + cGetInfo( GetLocal( n, j ) ) + CRLF
next
endif
n++
end
cErrorLog += CRLF + "Linked RDDs" + CRLF + "===========" + CRLF
aRDDs = RddList( 1 )
for n = 1 to Len( aRDDs )
cErrorLog += " " + aRDDs[ n ] + CRLF
next
cErrorLog += CRLF + "DataBases in use" + CRLF + "================" + CRLF
for n = 1 to 255
if ! Empty( Alias( n ) )
cErrorLog += CRLF + Str( n, 3 ) + ": " + If( Select() == n,"=> ", " " ) + ;
PadR( Alias( n ), 15 ) + Space( 20 ) + "RddName: " + ;
( Alias( n ) )->( RddName() ) + CRLF
cErrorLog += " ==============================" + CRLF
cErrorLog += " RecNo RecCount BOF EOF" + CRLF
cErrorLog += " " + Transform( ( Alias( n ) )->( RecNo() ), "9999999" ) + ;
" " + Transform( ( Alias( n ) )->( RecCount() ), "9999999" ) + ;
" " + cValToChar( ( Alias( n ) )->( BoF() ) ) + ;
" " + cValToChar( ( Alias( n ) )->( EoF() ) ) + CRLF + CRLF
if ( Alias( n ) )->( RddName() ) != "ARRAYRDD"
cErrorLog += " Indexes in use " + Space( 23 ) + "TagName" + CRLF
j = 1
while ! Empty( ( Alias( n ) )->( IndexKey( j ) ) )
cErrorLog += Space( 8 ) + ;
If( ( Alias( n ) )->( IndexOrd() ) == j, "=> ", " " ) + ;
PadR( ( Alias( n ) )->( IndexKey( j ) ), 35 ) + ;
( Alias( n ) )->( OrdName( j ) ) + ;
CRLF
j++
end
cErrorLog += CRLF + " Relations in use" + CRLF
for j = 1 to 8
if ! Empty( ( nTarget := ( Alias( n ) )->( DbRSelect( j ) ) ) )
cErrorLog += Space( 8 ) + Str( j ) + ": " + ;
"TO " + ( Alias( n ) )->( DbRelation( j ) ) + ;
" INTO " + Alias( nTarget ) + CRLF
// uValue = ( Alias( n ) )->( DbRelation( j ) )
// cErrorLog += cValToChar( &( uValue ) ) + CRLF
endif
next
endif
endif
next
n = 1
cErrorLog += CRLF + "Classes in use:" + CRLF
cErrorLog += "===============" + CRLF
#ifndef __XHARBOUR__
while ! Empty( __ClassName( n ) )
cErrorLog += " " + Str( n, 3 ) + " " + __ClassName( n++ ) + CRLF
end
#else
while n <= __ClsCntClasses()
cErrorLog += " " + Str( n, 3 ) + " " + __ClassName( n++ ) + CRLF
end
#endif
cErrorLog += CRLF + "Memory Analysis" + CRLF
cErrorLog += "===============" + CRLF
#ifdef __CLIPPER__
cErrorLog += " Static memory:" + CRLF
cErrorLog += " data segment: 64k" + CRLF
#endif
#ifdef __CLIPPER__
cErrorLog += " Initial size: " + ;
LTrim( Str( nInitDSSize() ) ) + ;
" bytes (SYMP=" + LTrim( Str( nSymPSize() ) ) + ;
", Stack=" + LTrim( Str( nStackSize() ) ) + ;
", Heap=" + LTrim( Str( nHeapSize() ) ) + ")" + CRLF
cErrorLog += " PRG Stack: " + ;
LTrim( Str( 65535 - ( nStatics() * 14 ) - nInitDSSize() ) ) + ;
" bytes" + CRLF
#endif
#ifdef __CLIPPER__
cErrorLog += " " + LTrim( Str( nStatics() ) ) + " Static variables: " + ;
LTrim( Str( nStatics() * 14 ) ) + " bytes" + CRLF + CRLF
#else
cErrorLog += " " + LTrim( Str( nStatics() ) ) + " Static variables" + ;
CRLF + CRLF
#endif
cErrorLog += " Dynamic memory consume:" + CRLF
cErrorLog += " Actual Value: " + Str( MemUsed() ) + " bytes" + CRLF
cErrorLog += " Highest Value: " + Str( MemMax() ) + " bytes" + CRLF
// Generates a file with an Error Log
/*
BEGIN SEQUENCE
oOldError = ErrorBlock( { || DoBreak() } )
MemoWrit( SetErrorPath() + SetErrorFileName(), cErrorLog )
END SEQUENCE
*/
// MUDEI EM: 09/01/2020 PARA MOSTRAR O ERRO NO PREVIEW
BEGIN SEQUENCE
oOldError = ErrorBlock( { || DoBreak() } )
MemoWrit( SetErrorPath() + SetErrorFileName(), cErrorLog )
// WinExec( "Notepad.exe /p error.log" ) // direto na impressora
// WinExec( "Notepad.exe error.log" )
// INCLUIDO EM: 09/01/2020 - Joao FWHX1601
cSeqErro := MemoRead( "ERROR.LOG" ) // Sequencia de erros
cError := ALLTRIM( cSeqErro )
PRINTER oPrn NAME "Erros do Programa - Envie Por Email Para o Suporte - Veja o Botão: @ Logo Abaixo" PREVIEW MODAL
DEFINE FONT oFont NAME "COURIER NEW" SIZE 0, -10 OF oPrn
oPrn:SetPage(9) // A4
oPrn:SetPortrait() //Vertical
PAGE
nLin:=1
FOR nLinha = 1 TO MLCOUNT( cError, 100 )
CURSORWAIT()
oPrn:CmSay( nLin := nLin +.4, 1.5, MEMOLINE( cError, 100, nLinha), oFont )
IF nLin > 25
nLin = 1
ENDPAGE
PAGE
ENDIF
SYSREFRESH()
NEXT
ENDPAGE
ENDPRINT
oFont:End()
END SEQUENCE
ErrorBlock( oOldError )
if bUserDlg == nil
DEFINE DIALOG oDlg ;
SIZE nDlgW, nDlgH ;
TITLE DLG_TITLE
oDlg:lTruePixel := .f.
@ 0, 20 SAY oSay PROMPT OemToAnsi( cMessage ) ;
CENTERED OF oDlg FONT oFont SIZE 400, 20
oSay:nStyle = nOR( oSay:nStyle, 128 ) // SS_NOPREFIX
oSay:nTop = 3
oSay:nLeft = 52
oSay:nBottom = 25
oSay:nRight = 168
@ 24, 6 SAY "&Stack List" OF oDlg FONT oFont PIXEL
n = aStack[ 1 ]
@ nTopLbx, 3 LISTBOX oLbx VAR n ITEMS aStack OF oDlg ;
SIZE nLbxW, nLbxH PIXEL
if e:CanRetry
if nButtons == 2
nLeftR := ( ( 1.5 * nDlgW ) - ( nButtons * nBtnW ) ) / ( 2 * nButtons )
else
nLeftR := ( nDlgW / 12 ) - ( nBtnW / 2 )
endif
@ nTopBtn, nLeftR BUTTON "&Retry" ;
OF oDlg ACTION ( lRet := .t., oDlg:End() ) ;
SIZE nBtnW, nBtnH FONT oFont PIXEL
endif
if nButtons == 1 .or. nButtons == 3
nLeftQ = ( nDlgW / 4 ) - ( nBtnW / 2 )
@ nTopBtn, nLeftQ BUTTON "&Quit" OF oDlg ACTION oDlg:End() ;
SIZE nBtnW, nBtnH PIXEL FONT oFont DEFAULT
else
nLeftQ = ( nDlgW / ( 4 * nButtons ) ) - ( nBtnW / 2 )
@ nTopBtn, nLeftQ BUTTON "&Quit" OF oDlg ACTION oDlg:End() ;
SIZE nBtnW, nBtnH PIXEL FONT oFont
endif
if e:CanDefault
nLeftD = nDlgW / 3 + nLeftR
@ nTopBtn, nLeftD BUTTON "&Default" OF oDlg ;
ACTION ( lRet := .f., oDlg:End() ) ;
SIZE nBtnW, nBtnH FONT oFont PIXEL
endif
/*
@ 21, 175 BUTTON "See " + SetErrorFileName() + " file" OF oDlg FONT oFont PIXEL ;
SIZE 46, 10 ;
ACTION WinExec( "Notepad.exe " + SetErrorPath() + SetErrorFileName() )
*/
// MUDEI EM: 31/01/2020 - Joao
@ 21, 175 BUTTON "Veja " + SetErrorFileName() + " " OF oDlg FONT oFont PIXEL ;
SIZE 46, 10 ;
ACTION WinExec( "Notepad.exe " + SetErrorPath() + SetErrorFileName() )
ACTIVATE DIALOG oDlg CENTERED ;
ON PAINT DrawBitmap( hDC, hLogo, 6, 6 )
else
Eval( bUserDlg, e, aStack, cErrorLog, SetErrorPath() + SetErrorFileName() )
endif
DeleteObject( hLogo )
if bUserAction != nil
Eval( bUserAction, SetErrorPath() + SetErrorFileName(), e )
endif
if lRet == nil .or. ( !LWRunning() .and. lRet )
SET RESOURCES TO
ErrorLevel( 1 )
// Add these lines if using MDI child windows with dialogboxes
// for n = 1 to Len( GetAllWin() )
// if ValType( GetAllWin()[ n ] ) == "O"
// GetAllWin()[ n ]:UnLink()
// endif
// next
lEnviouErroLog := .T.
// SEND EMAIL WIRH ERROR.LOG
Envia_Error_Log() // ESTA EM: FUNCOES.PRG
QUIT // must be QUIT !!!
endif
return lRet
//----------------------------------------------------------------------------//
static function DoBreak()
BREAK
return nil
//----------------------------------------------------------------------------//
static func ErrorMessage( e )
// start error message
local cMessage := if( empty( e:OsCode ), ;
if( e:severity > ES_WARNING, "Error ", "Warning " ),;
"(DOS Error " + NTRIM(e:osCode) + ") " )
// add subsystem name if available
cMessage += if( ValType( e:SubSystem ) == "C",;
e:SubSystem() ,;
"???" )
// add subsystem's error code if available
cMessage += if( ValType( e:SubCode ) == "N",;
"/" + NTRIM( e:SubCode ) ,;
"/???" )
// add error description if available
if ( ValType( e:Description ) == "C" )
cMessage += " " + e:Description
end
// add either filename or operation
cMessage += if( ! Empty( e:FileName ),;
": " + e:FileName ,;
if( !Empty( e:Operation ),;
": " + e:Operation ,;
"" ) )
return cMessage
//----------------------------------------------------------------------------//
// returns extended info for a certain variable type
static function cGetInfo( uVal )
local cType := ValType( uVal )
do case
case cType == "C"
return '"' + cValToChar( uVal ) + '"'
case cType == "O"
return "Class: " + uVal:ClassName()
case cType == "A"
return "Len: " + Str( Len( uVal ), 4 )
otherwise
return cValToChar( uVal )
endcase
return nil
//----------------------------------------------------------------------------//
#define HKEY_LOCAL_MACHINE 2147483650 // 0x80000002
function GetCPU()
local oReg := TReg32():New( HKEY_LOCAL_MACHINE,;
"HARDWARE\DESCRIPTION\System\CentralProcessor\0",;
.f. )
local cCpu := oReg:Get( "ProcessorNameString" )
oReg:Close()
return cCpu
//----------------------------------------------------------------------------//
#ifdef __HARBOUR__
#ifndef __XHARBOUR__
REQUEST HB_GT_GUI_DEFAULT
PROCEDURE HB_GTSYS() ; return
procedure FW_GT ; return
#endif
#endif
//----------------------------------------------------------------------------//
FUNCTION DOSERRO( QUAL ) // INCLUIDO EM: 22/04/2021 ERROS DE REDE...
PRIVATE FALHA[ 999 ]
IF QUAL = 0 .OR. QUAL > 120
QUAL = 999
ENDIF
FALHA[ 1 ] = "NUMERO DE FUNCAO INVALIDA"
// MUDEI EM: 24/02/2016 Para ficar mais claro a mensagem.
FALHA[ 2 ] = "ARQUIVO NAO ENCONTRADO NA PASTA DO PLENO: VERIFIQUE SUA REDE. "+ ;
"TEM UMA FALHA DE COMUNICACAO DO SEU COMPUTADOR COM O SERVIDOR "+ ;
"DE ARQUIVOS."
FALHA[ 3 ] = "CAMINHO OU ARQUIVO NAO ENCONTRADO"
FALHA[ 4 ] = "MUITOS ARQUIVOS ABERTOS"
FALHA[ 5 ] = "ACESSO NEGADO - LIBERE O ACESSO A PASTA ACIMA - CHAME O TECNICO."
FALHA[ 6 ] = "HANDLE INVALIDO - PROBELMAS NO HD."
FALHA[ 7 ] = "BLOCO DE CONTROLE DE MEMORIA DESTRUIDO"
FALHA[ 8 ] = "MEMORIA INSUFICIENTE - COLOQUE MAIS MEMORIA RAM"
FALHA[ 9 ] = "ENDERECO DE BLOCO DE MEMORIA INVALIDO"
FALHA[ 10 ] = "DISPOSITIVO INVALIDO"
FALHA[ 11 ] = "FORMATACAO INVALIDA"
FALHA[ 12 ] = "CODIGO DE ACESSO INVALIDO"
FALHA[ 13 ] = "DADOS INVALIDOS"
FALHA[ 14 ] = "RESERVADO PARA USO FUTURO 14"
FALHA[ 15 ] = "ACIONADOR DE DISCO(DRIVE) INVALIDO"
FALHA[ 16 ] = "TENTOU REMOVER DO DIRETORIO CORRENTE"
FALHA[ 17 ] = "DISPOSITIVO NAO E O MESMO"
FALHA[ 18 ] = "NAO HA MAIS ARQUIVO"
FALHA[ 19 ] = "DISCO PROTEGIDO CONTRA GRAVACAO - LIBERE O ACESSO DO HD."
FALHA[ 20 ] = "UNIDADE DE DISCO DESCONHECIDA"
FALHA[ 21 ] = "IMPOSSIVEL LEITURA DE DISCO - CHAME O TECNICO."
FALHA[ 22 ] = "COMANDO DESCONHECIDO"
FALHA[ 23 ] = "INFORMACAO ERRADA(CRC)"
FALHA[ 24 ] = "COMPRIMENTO DA ESTRUTURA ESTA RUIM"
FALHA[ 25 ] = "ERRO NA PESQUISA(SEEK)"
FALHA[ 26 ] = "UNIDADE DE ARMAZENAGEM(MIDIA) DESCONHECIDO"
FALHA[ 27 ] = "SETOR NAO ENCONTRADO - PROBLEMAS NO HD."
FALHA[ 28 ] = "ACABOU O PAPEL DA IMPRESSORA"
FALHA[ 29 ] = "GRAVACAO INVALIDA"
FALHA[ 30 ] = "LEITURA INVALIDA"
FALHA[ 31 ] = "FALHA GERAL- CHAME O TECNICO URGENTE."
FALHA[ 32 ] = "VIOLACAO DE COMPARTILHAMENTO"
FALHA[ 33 ] = "TENTATIVA DE ACESSAR UM ARQUIVO BLOQUEADO"
FALHA[ 34 ] = "MUDANCA DE DISCO INVALIDA"
FALHA[ 35 ] = "TENTATIVA DE ABRIR MAIS ARQUIVOS DO QUE O DEFINIDO NO COMANDO FCBS."
FALHA[ 36 ] = "ESTOURO NO BUFFER DE COMPARTILHAMENTO."
FALHA[ 37 ] = "RESERVADO PARA USO FUTURO 37"
FALHA[ 38 ] = "RESERVADO PARA USO FUTURO 38"
FALHA[ 39 ] = "RESERVADO PARA USO FUTURO 39"
FALHA[ 40 ] = "RESERVADO PARA USO FUTURO 40"
FALHA[ 41 ] = "RESERVADO PARA USO FUTURO 41"
FALHA[ 42 ] = "RESERVADO PARA USO FUTURO 42"
FALHA[ 43 ] = "RESERVADO PARA USO FUTURO 43"
FALHA[ 44 ] = "RESERVADO PARA USO FUTURO 44"
FALHA[ 45 ] = "RESERVADO PARA USO FUTURO 45"
FALHA[ 46 ] = "RESERVADO PARA USO FUTURO 46"
FALHA[ 47 ] = "RESERVADO PARA USO FUTURO 47"
FALHA[ 48 ] = "RESERVADO PARA USO FUTURO 48"
FALHA[ 49 ] = "RESERVADO PARA USO FUTURO 49"
FALHA[ 50 ] = "REDE REQUERIDA NAO SUPORTADA"
FALHA[ 51 ] = "COMPUTADOR REMOTO NAO ESTA RESPONDENDO"
FALHA[ 52 ] = "NOME DA REDE DUPLICADO"
FALHA[ 53 ] = "NOME DA REDE NAO ENCONTRADO"
FALHA[ 54 ] = "REDE OCUPADA."
FALHA[ 55 ] = "DISPOSITIVO DE REDE NAO MAIS EXISTENTE"
FALHA[ 56 ] = "LIMITE DE COMANDOS DA BIOS EXCEDIDO"
FALHA[ 57 ] = "ERRO DE HARDWARE NA PLACA DA REDE"
FALHA[ 58 ] = "RESPOSTA INCORRETA DA REDE"
FALHA[ 59 ] = "ERRO INESPERADO NA REDE - CHAME O TECNICO DE REDE."
FALHA[ 60 ] = "PLACA REMOTA INCOMPATIVEL"
FALHA[ 61 ] = "FILA DE IMPRESSAO ESTA CHEIA"
FALHA[ 62 ] = "NAO EXISTE ESPACO SUFICIENTE PARA O ARQUIVO DE IMPRESSAO."
FALHA[ 63 ] = "ARQUIVO DE IMPRESSAO ELIMINADO(ESPACO INSUFICIENTE)"
FALHA[ 64 ] = "NOME DA REDE ELIMINADO/SERVIDOR NAO ENCONTRADO"
FALHA[ 65 ] = "ACESSO NAO PERMITIDO - LIBERE O ACESSO A PASTA ACIMA."
FALHA[ 66 ] = "TIPO INCORRETO DE DISPOSITIVO DE REDE"
FALHA[ 67 ] = "NOME DA REDE NAO ENCONTRADO"
FALHA[ 68 ] = "LIMITE EXCEDIDO PARA O NOME DA REDE"
FALHA[ 69 ] = "LIMITE DE SESSAO DA BIOS EXCEDIDO NA REDE"
FALHA[ 70 ] = "PAUSA TEMPORARIA"
FALHA[ 71 ] = "PEDIDO DE REDE NEGADO"
FALHA[ 72 ] = "DISPOSITIVO DA IMPRESSORA OU DISCO PAUSADO."
FALHA[ 73 ] = "RESERVADO PARA USO FUTURO 73"
FALHA[ 74 ] = "RESERVADO PARA USO FUTURO 74"
FALHA[ 75 ] = "RESERVADO PARA USO FUTURO 75"
FALHA[ 76 ] = "RESERVADO PARA USO FUTURO 76"
FALHA[ 77 ] = "MEMORIA INSUFICIENTE PARA OPERAR O EQUIPAMENTO. CHAME O TECNICO."
FALHA[ 78 ] = "RESERVADO PARA USO FUTURO 78"
FALHA[ 79 ] = "RESERVADO PARA USO FUTURO 79"
FALHA[ 80 ] = "ARQUIVO JA EXISTENTE NO DISCO(HD)"
FALHA[ 81 ] = "RESERVADO PARA USO FUTURO 81"
FALHA[ 82 ] = "IMPOSSIVEL CRIAR DIRETORIO"
FALHA[ 83 ] = "OCORREU FALHA EM INT 24H DO DOS"
FALHA[ 84 ] = "EXCESSOS DE REDIRECIONAMENTOS"
FALHA[ 85 ] = "REDIRECIONAMENTO DUPLICADO"
FALHA[ 86 ] = "SENHA INVALIDA"
FALHA[ 87 ] = "PARAMETRO INVALIDO OU INCORRETO."
FALHA[ 88 ] = "ERRO AO ESCREVER PARA A REDE. DEFEITO TCNICO."
FALHA[ 89 ] = "NENHUM ERRO OCORRIDO!"
FALHA[ 90 ] = "erro de sistema."
FALHA[ 91 ] = "Temporizador da tabela do serviço de transbordo."
FALHA[ 92 ] = "Temporizador serviço tabela duplicar."
FALHA[ 93 ] = "Nenhum item para trabalhar."
FALHA[ 95 ] = "chamada de sistema interrompida."
FALHA[ 99 ] = "Dispositivo em uso."
FALHA[100] = "usuário / sistema de limite de abertura do semáforo atingido."
FALHA[101] = "Exclusivo semáforo já possuía."
FALHA[102] = "DosCloseSem encontrada conjunto de semáforos."
FALHA[103] = "Há muitas solicitações de semáforos exclusivos."
FALHA[104] = "Operação inválida em tempo de interrupção."
FALHA[105] = "proprietário do semáforo anterior encerrado sem libertar semáforo."
FALHA[106] = "limite de Semaphore excedido."
FALHA[107] = "Insira o disco rígido B na unidade A."
FALHA[108] = "Unidade bloqueado por outro processo."
FALHA[109] = "Escreva no tubo com nenhum leitor."
FALHA[110] = "Open / Create falhou devido a ordem explícita falhar."
FALHA[111] = "Tampão passado para chamada de sistema muito pequeno para armazenar dados de retorno."
FALHA[112] = "Não há espaço suficiente no disco. Disco Cheio. Chame o Tecnico."
FALHA[113] = "Não é possível alocar uma outra estrutura de pesquisa e manusear."
FALHA[114] = "Alvo punho em DosDupHandle inválido."
FALHA[115] = "Usuário inválido endereço virtual."
FALHA[116] = "Erro na gravação de exibição ou o teclado ler."
FALHA[117] = "Categoria de DevIOCtl não definido."
FALHA[118] = "valor inválido passado para verificar bandeira."
FALHA[119] = "Nível quatro motorista não foi encontrado."
FALHA[120] = "Função Chamada inválida."
FALHA[161] = "Nome do caminho do PLENO inválido. Verifique o Icone se o caminho esta igual ao do PLENO"
FALHA[999] = "ERRO NAO CATALOGADO INFORME O NUMERO DO ERRO AO SUPORTE."
/*
Na maioria das vezes estes erros estão relacionados a uma falha de Hardware
(parte fisica do computador)
*/
RETURN( "PROBLEMA: " + FALHA[ QUAL ] )
// FIM DO PROGRAMA - 22/04/2021 - Joao
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: Enhance errorsys.prg
hi,
1st. Errorsys, load at Startup, is "last Chance" to retry ... but most it is "too late"
at Runtime i do use BEGIN SEQUENCE and a "new" Errorblock.
depend on "oError" you can try to "react" on it
so write a Function where you handle "open" DBF / Index and put your Code into BEGIN / END SEQUENCE
1st. Errorsys, load at Startup, is "last Chance" to retry ... but most it is "too late"

at Runtime i do use BEGIN SEQUENCE and a "new" Errorblock.
depend on "oError" you can try to "react" on it
Code: Select all | Expand
LOCAL oError, bError
bError := ERRORBLOCK( { | oErr | BREAK( oErr ) } )
BEGIN SEQUENCE
// your Code
RECOVER USING oError
ERRORBLOCK( bError )
// here to react on Error
Msgbox( oError:description +CRLF+ oError:operation + STR( oError:SubCode ), "DOS Error" + STR( oError:OsCode ) )
RETURN .F.
END SEQUENCE
ERRORBLOCK( bError )
so write a Function where you handle "open" DBF / Index and put your Code into BEGIN / END SEQUENCE
greeting,
Jimmy
Jimmy
Re: Enhance errorsys.prg
Code: Select all | Expand
local e
TRY
Dbusearea( .....
CATCH e
MsgInfo( e:Description, "Error" )
END
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
- Marc Venken
- Posts: 1485
- Joined: Tue Jun 14, 2016 7:51 am
- Location: Belgium
Re: Enhance errorsys.prg
Thanks all.
I will put this technique into a netopen(..) function
How do you catch errors like : Argument error ..... I mean errors that now an then appear because of bad programming )))
A Logfile is created, but I would like to have a nice error screen.
Do I have to change the FW error system for this?
I will put this technique into a netopen(..) function
How do you catch errors like : Argument error ..... I mean errors that now an then appear because of bad programming )))
A Logfile is created, but I would like to have a nice error screen.
Do I have to change the FW error system for this?
Marc Venken
Using: FWH 23.08 with Harbour
Using: FWH 23.08 with Harbour