Jump to content
Fivewin Brasil

GPFHANDLE()


kapiaba

Recommended Posts

Galera, onde econtro esta função completa, e como a invoco no sistema?  Obg. abs.

&& ------------------------------
FUNCTION gpfHandler( oException )
&& ------------------------------
	LOCAL oError
	LOCAL cMensagemErro := ""
LOCAL nCodigoErro   := 0
	
&& -- Verificando se oException é um objeto para iniciar o tratamento
IF typeCheck( oException, "O" )
	   nCodigoErro := oException:ExceptionRecord:ExceptionCode
	   && -- Verificando qual tipo de exceção foi levantada
   SWITCH nCodigoErro
	          CASE EXCEPTION_ACCESS_VIOLATION
               cMensagemErro := "EXCEPTION_ACCESS_VIOLATION - O thread tentou ler/escrever num endereço virtual ao qual não tinha acesso."
               EXIT
	          CASE EXCEPTION_DATATYPE_MISALIGNMENT
               cMensagemErro := "EXCEPTION_DATATYPE_MISALIGNMENT - O thread tentou ler/escrever dados desalinhados em hardware que não oferece alinhamento. Por exemplo, valores de 16 bits precisam ser alinhados em limites de 2 bytes; valores de 32 bits em limites de 4 bytes, etc. "
               EXIT
	          CASE EXCEPTION_ARRAY_BOUNDS_EXCEEDED
               cMensagemErro := "EXCEPTION_ARRAY_BOUNDS_EXCEEDED - O thread tentou acessar um elemento de array fora dos limites e o hardware possibilita a checagem de limites."
               EXIT
	          CASE EXCEPTION_FLT_DENORMAL_OPERAND
               cMensagemErro := "EXCEPTION_FLT_DENORMAL_OPERAND - Um dos operandos numa operação de ponto flutuante está desnormatizado. Um valor desnormatizado é um que seja pequeno demais para poder ser representado no formato de ponto flutuante padrão."
               EXIT
	          CASE EXCEPTION_FLT_DIVIDE_BY_ZERO
               cMensagemErro := "EXCEPTION_FLT_DIVIDE_BY_ZERO - O thread tentou dividir um valor em ponto flutuante por um divisor em ponto flutuante igual a zero."
               EXIT
	          CASE EXCEPTION_FLT_INEXACT_RESULT
               cMensagemErro := "EXCEPTION_FLT_INEXACT_RESULT - O resultado de uma operação de ponto flutuante não pode ser representado como uma fração decimal exata."
               EXIT
	          CASE EXCEPTION_FLT_INVALID_OPERATION
               cMensagemErro := "EXCEPTION_FLT_INVALID_OPERATION - Qualquer operação de ponto flutuante não incluída na lista."
               EXIT
	          CASE EXCEPTION_FLT_OVERFLOW
               cMensagemErro := "EXCEPTION_FLT_OVERFLOW - O expoente de uma operação de ponto flutuante é maior que a magnitude permitida pelo tipo correspondente."
               EXIT
	          CASE EXCEPTION_FLT_STACK_CHECK
               cMensagemErro := 'EXCEPTION_FLT_STACK_CHECK - A pilha ficou desalinhada ("estourou" ou "ficou abaixo") como resultado de uma operação de ponto flutuante.'
               EXIT
	          CASE EXCEPTION_FLT_UNDERFLOW
               cMensagemErro := "EXCEPTION_FLT_UNDERFLOW - O expoente de uma operação de ponto flutuante é menor que a magnitude permitida pelo tipo correspondente."
               EXIT
	          CASE EXCEPTION_INT_DIVIDE_BY_ZERO
               cMensagemErro := "EXCEPTION_INT_DIVIDE_BY_ZERO - O thread tentou dividir um valor inteiro por um divisor inteiro igual a zero."
               EXIT
	          CASE EXCEPTION_INT_OVERFLOW
               cMensagemErro := "EXCEPTION_INT_OVERFLOW - O resultado de uma operação com inteiros causou uma transposição (carry) além do bit mais significativo do resultado."
               EXIT
	          CASE EXCEPTION_PRIV_INSTRUCTION
               cMensagemErro := "EXCEPTION_PRIV_INSTRUCTION - O thread tentou executar uma instrução cuja operação não é permitida no modo de máquina atual."
               EXIT
	          CASE EXCEPTION_IN_PAGE_ERROR
               cMensagemErro := "EXCEPTION_IN_PAGE_ERROR - O thread tentou acessar uma página que não estava presente e o sistema não foi capaz de carregar a página. Esta exceção pode ocorrer, por exemplo, se uma conexão de rede é perdida durante a execução do programa via rede."
               EXIT
	          CASE EXCEPTION_ILLEGAL_INSTRUCTION
               cMensagemErro := "EXCEPTION_ILLEGAL_INSTRUCTION - O thread tentou executar uma instrução inválida."
               EXIT
	          CASE EXCEPTION_NONCONTINUABLE_EXCEPTION
               cMensagemErro := "EXCEPTION_NONCONTINUABLE_EXCEPTION - O thread tentou continuar a execução após a ocorrência de uma exceção irrecuperável."
               EXIT
	          CASE EXCEPTION_STACK_OVERFLOW
               cMensagemErro := "EXCEPTION_STACK_OVERFLOW - O thread esgotou sua pilha (estouro de pilha)."
               EXIT
	          CASE EXCEPTION_INVALID_DISPOSITION
               cMensagemErro := "EXCEPTION_INVALID_DISPOSITION - Um manipulador (handle) de exceções retornou uma disposição inválida para o tratador de exceções. Uma exceção deste tipo nunca deveria ser encontrada em linguagens de médio/alto nível."
               EXIT
	          CASE EXCEPTION_GUARD_PAGE
               cMensagemErro := "CASE EXCEPTION_GUARD_PAGE"
               EXIT
	          CASE EXCEPTION_INVALID_HANDLE
               cMensagemErro := "EXCEPTION_INVALID_HANDLE"
               EXIT
	          CASE EXCEPTION_SINGLE_STEP
               cMensagemErro := "EXCEPTION_SINGLE_STEP Um interceptador de passos ou outro mecanismo de instrução isolada sinalizou que uma instrução foi executada."
               EXIT
	          CASE EXCEPTION_BREAKPOINT
               cMensagemErro := "EXCEPTION_BREAKPOINT - Foi encontrado um ponto de parada (breakpoint)."
               EXIT
	          DEFAULT
              cMensagemErro := "UNKNOWN EXCEPTION ( " + cStr( oException:ExceptionRecord:ExceptionCode ) + " )"
	   END
	ENDIF
	&& -- Verificando se houve erro GPF a nível das TDialogs
oError := errorNew( "GPFHANDLER", 0, 0, procName(), "GPF - Erro Geral de Processo", { cMensagemErro, oException, nCodigoErro }, procFile(), procName(), procLine() )
	errorDialog( oError )
	RETURN( EXCEPTION_EXECUTE_HANDLER )


Link to comment
Share on other sites

Boa tarde Kapi, tudo tranquilo?

Coloque esta linha no Main()

SetUnhandledExceptionFilter( @GpfHandler() ) e, compile o prg abaixo junto com seu sistema


// Error handler system adapted to FiveWin
// ErrSysW.prg

#include "FiveWin.ch"
#include "error.ch"

external _fwGenError   // Link FiveWin generic Error Objects Generator

#define NTRIM(n)    ( LTrim( Str( n ) ) )

#ifdef __CLIPPER__
   #define DLG_TITLE "FiveWin: The CA-Clipper for Windows Library"
#else
   #ifdef __HARBOUR__
      #define DLG_TITLE "FiveWin for (x)Harbour"
      #command QUIT => ( PostQuitMessage( 0 ), __Quit() )
   #else
      #define DLG_TITLE "FiveWin for Xbase++"
   #endif
#endif

/*************
*ErrorSys()
*
*Note:  automatically executes at startup
*/
procedure ErrorSys()
    ErrorBlock( { | e | ErrorDialog( e ) } )
Return

procedure ErrorLink()
Return

/*************
*   ErrorDialog()
*/
//static function ErrorDialog( e ) // -> logical or quits App.
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()

   // by default, division by zero yields zero
   if ( e:genCode == EG_ZERODIV )
      return 0
   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.       // Warning: Exiting!
   endif

   // 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

   ErrorBlock( {|e| MsgStop( ErrorMessage(e) + " from Errorsys, line:" + ;
                             Str( ProcLine( 1 ), 3 ) ), __quit() } )

   cErrorLog += "Application" + CRLF
   cErrorLog += "===========" + CRLF
   cErrorLog += "   Path and name: " + GetModuleFileName( GetInstance() )

   #ifdef __CLIPPER__
      cErrorLog += " (16 bits)" + CRLF
   #else
      cErrorLog += " (32 bits)" + CRLF
   #endif

   cErrorLog += "   Size: " + Transform( FSize( GetModuleFileName( ;
                GetInstance() ) ), "9,999,999 bytes" ) + CRLF
   #ifdef __CLIPPER__
      cErrorLog += "   Max files handles permited: ( SetHandleCount() ) " + ;
                   Str( SetHandleCount(), 3 ) + CRLF
   #endif

   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 ValType( e:Args ) == "A"
      cErrorLog += "   Args:" + CRLF
      for n = 1 to Len( e:Args )
         cErrorLog += "     [" + Str( n, 4 ) + "] = " + ValType( e:Args[ n ] ) + ;
                      "   " + cValToChar( 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 " + 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
      cErrorLog += "   CPU type: " + GetCPU() + " " + ;
                   AllTrim( Str( GetCPUSpeed() ) ) + " Mhz" + CRLF
   #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

   cErrorLog += "   Compiler version: " + Version() + 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

   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 = FWBitMap()

   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() ), "99999" ) + ;
                      "      " + Transform( ( Alias( n ) )->( RecCount() ), "99999" ) + ;
                      "      " + cValToChar( ( Alias( n ) )->( BoF() ) ) + ;
                      "   " + cValToChar( ( Alias( n ) )->( EoF() ) ) + CRLF + CRLF
         cErrorLog += "     Indexes in use " + Space( 23 ) + "TagName" + CRLF
         for j = 1 to 15
            if ! Empty( ( Alias( n ) )->( IndexKey( j ) ) )
               cErrorLog += Space( 8 ) + ;
                            If( ( Alias( n ) )->( IndexOrd() ) == j, "=> ", "   " ) + ;
                            PadR( ( Alias( n ) )->( IndexKey( j ) ), 35 ) + ;
                            ( Alias( n ) )->( OrdName( j ) ) + ;
                            CRLF
            endif
         next
         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
   next

   n = 1
   cErrorLog += CRLF + "Classes in use:" + CRLF
   cErrorLog += "===============" + CRLF
   while ! Empty( __ClassName( n ) )
      cErrorLog += "   " + Str( n, 3 ) + " " + __ClassName( n++ ) + CRLF
   end

   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
   // nSymNames() no longer returns a real value! 15/April/97
   /*
   cErrorLog += "   SYMBOLS segment" + CRLF
   cErrorLog += "      " + LTrim( Str( nSymNames() ) ) + " SymbolNames:   " + ;
                LTrim( Str( nSymNames() * 16 ) ) + " bytes"
   */

   // Generates a file with an Error Log

   BEGIN SEQUENCE
      oOldError = ErrorBlock( { || DoBreak() } )
      MemoWrit( "Error.log", cErrorLog )
   END SEQUENCE
   ErrorBlock( oOldError )

   DEFINE DIALOG oDlg ;
      SIZE 300, 200 + If( lIsWinNT, 50, 0 ) ;
      TITLE DLG_TITLE

   @ 0, 0 SAY oSay PROMPT OemToAnsi( cMessage ) ;
      CENTERED OF oDlg FONT oFont SIZE 149, 20

   oSay:nStyle   = nOR( oSay:nStyle, 128 )   // SS_NOPREFIX
   oSay:nTop     =   3
   oSay:nLeft    =  22
   oSay:nBottom  =  25
   oSay:nRight   = 148

   @ 24,   6 SAY "&Stack List" OF oDlg FONT oFont PIXEL

   n = aStack[ 1 ]

   @ 33, 3 LISTBOX oLbx VAR n ITEMS aStack OF oDlg ;
      SIZE 145, 60 + If( lIsWinNT, 18, 0 ) PIXEL

   if nButtons == 1 .or. nButtons == 3
      @ 88 + If( lIsWinNT, 24, 0 ), 60 BUTTON "&Quit" OF oDlg ACTION oDlg:End() ;
         SIZE 30, 11 PIXEL FONT oFont DEFAULT
   else
      @ 88 + If( lIsWinNT, 24, 0 ), 37 BUTTON "&Quit" OF oDlg ACTION oDlg:End() ;
         SIZE 30, 11 PIXEL FONT oFont
   endif

   if e:CanRetry
      @ 88 + If( lIsWinNT, 24, 0 ), If( nButtons == 2, 82, 13 ) BUTTON "&Retry" ;
         OF oDlg ACTION ( lRet  := .t., oDlg:End() ) ;
         SIZE 30, 11 FONT oFont PIXEL
   endif

   if e:CanDefault
      @ 88 + If( lIsWinNT, 24, 0 ), 108 BUTTON "&Default"  OF oDlg ;
         ACTION ( lRet  := .f., oDlg:End() ) ;
         SIZE 30, 11 FONT oFont PIXEL
   endif

   @ 21, 100 BUTTON "See Error.log file" OF oDlg FONT oFont PIXEL ;
      SIZE 47, 10 ;
      ACTION WinExec( "Notepad.exe error.log" )

   ACTIVATE DIALOG oDlg CENTERED ;
      ON PAINT DrawBitmap( hDC, hLogo, 6, 6 )

   DeleteObject( hLogo )

   if lRet == nil .or. ( !LWRunning() .and. lRet )
      SET RESOURCES TO
      ErrorLevel( 1 )
      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
  endif

// 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
//----------------------------------------------------------------------------//

#include "hbexcept.ch"

//----------------------------------------------------------------------------//
Function GpfHandler( Exception )

   local cMsg, nCode, oError

   //  TraceLog( "GPF:", Exception )
   //  memowrit( "gpf.txt", valtoprg( Exception ) )

   IF Exception <> NIL
      nCode := Exception:ExceptionRecord:ExceptionCode
      SWITCH nCode
         CASE EXCEPTION_ACCESS_VIOLATION
              cMsg := "EXCEPTION_ACCESS_VIOLATION - O thread tentou ler/escrever num endereço virtual ao qual não tinha acesso." 
              EXIT

         CASE EXCEPTION_DATATYPE_MISALIGNMENT
              cMsg := "EXCEPTION_DATATYPE_MISALIGNMENT - O thread tentou ler/escrever dados desalinhados em hardware que não oferece alinhamento. Por exemplo, valores de 16 bits precisam ser alinhados em limites de 2 bytes; valores de 32 bits em limites de 4 bytes, etc. "
              EXIT

         CASE EXCEPTION_ARRAY_BOUNDS_EXCEEDED

              cMsg := "EXCEPTION_ARRAY_BOUNDS_EXCEEDED - O thread tentou acessar um elemento de array fora dos limites e o hardware possibilita a checagem de limites."
              EXIT

         CASE EXCEPTION_FLT_DENORMAL_OPERAND
              cMsg := "EXCEPTION_FLT_DENORMAL_OPERAND - Um dos operandos numa operação de ponto flutuante está desnormatizado. Um valor desnormatizado é um que seja pequeno demais para poder ser representado no formato de ponto flutuante padrão."
              EXIT

         CASE EXCEPTION_FLT_DIVIDE_BY_ZERO
              cMsg := "EXCEPTION_FLT_DIVIDE_BY_ZERO - O thread tentou dividir um valor em ponto flutuante por um divisor em ponto flutuante igual a zero."
              EXIT

         CASE EXCEPTION_FLT_INEXACT_RESULT
              cMsg := "EXCEPTION_FLT_INEXACT_RESULT - O resultado de uma operação de ponto flutuante não pode ser representado como uma fração decimal exata."
              EXIT

         CASE EXCEPTION_FLT_INVALID_OPERATION
              cMsg := "EXCEPTION_FLT_INVALID_OPERATION - Qualquer operação de ponto flutuante não incluída na lista."
              EXIT

         CASE EXCEPTION_FLT_OVERFLOW
              cMsg := "EXCEPTION_FLT_OVERFLOW - O expoente de uma operação de ponto flutuante é maior que a magnitude permitida pelo tipo correspondente."
              EXIT

         CASE EXCEPTION_FLT_STACK_CHECK
              cMsg := 'EXCEPTION_FLT_STACK_CHECK - A pilha ficou desalinhada ("estourou" ou "ficou abaixo") como resultado de uma operação de ponto flutuante.'
              EXIT

         CASE EXCEPTION_FLT_UNDERFLOW
              cMsg := "EXCEPTION_FLT_UNDERFLOW - O expoente de uma operação de ponto flutuante é menor que a magnitude permitida pelo tipo correspondente."
              EXIT

         CASE EXCEPTION_INT_DIVIDE_BY_ZERO
              cMsg := "EXCEPTION_INT_DIVIDE_BY_ZERO - O thread tentou dividir um valor inteiro por um divisor inteiro igual a zero."
              EXIT

         CASE EXCEPTION_INT_OVERFLOW
              cMsg := "EXCEPTION_INT_OVERFLOW - O resultado de uma operação com inteiros causou uma transposição (carry) além do bit mais significativo do resultado."
              EXIT

         CASE EXCEPTION_PRIV_INSTRUCTION
              cMsg := "EXCEPTION_PRIV_INSTRUCTION - O thread tentou executar uma instrução cuja operação não é permitida no modo de máquina atual."
              EXIT

         CASE EXCEPTION_IN_PAGE_ERROR
              cMsg := "EXCEPTION_IN_PAGE_ERROR - O thread tentou acessar uma página que não estava presente e o sistema não foi capaz de carregar a página. Esta exceção pode ocorrer, por exemplo, se uma conexão de rede é perdida durante a execução do programa via rede."
              EXIT

         CASE EXCEPTION_ILLEGAL_INSTRUCTION
              cMsg := "EXCEPTION_ILLEGAL_INSTRUCTION - O thread tentou executar uma instrução inválida."
              EXIT

         CASE EXCEPTION_NONCONTINUABLE_EXCEPTION
              cMsg := "EXCEPTION_NONCONTINUABLE_EXCEPTION - O thread tentou continuar a execução após a ocorrência de uma exceção irrecuperável."
              EXIT

         CASE EXCEPTION_STACK_OVERFLOW
              cMsg := "EXCEPTION_STACK_OVERFLOW - O thread esgotou sua pilha (estouro de pilha)."
              EXIT

         CASE EXCEPTION_INVALID_DISPOSITION
              cMsg := "EXCEPTION_INVALID_DISPOSITION - Um manipulador (handle) de exceções retornou uma disposição inválida para o tratador de exceções. Uma exceção deste tipo nunca deveria ser encontrada em linguagens de médio/alto nível."
              EXIT

         CASE EXCEPTION_GUARD_PAGE
              cMsg := "CASE EXCEPTION_GUARD_PAGE"
              EXIT

         CASE EXCEPTION_INVALID_HANDLE
              cMsg := "EXCEPTION_INVALID_HANDLE"
              EXIT

         CASE EXCEPTION_SINGLE_STEP
              cMsg := "EXCEPTION_SINGLE_STEP Um interceptador de passos ou outro mecanismo de instrução isolada sinalizou que uma instrução foi executada."
              EXIT

         CASE EXCEPTION_BREAKPOINT
              cMsg := "EXCEPTION_BREAKPOINT - Foi encontrado um ponto de parada (breakpoint)."
              EXIT

         DEFAULT
            cMsg := "UNKNOWN EXCEPTION (" + cStr( Exception:ExceptionRecord:ExceptionCode ) + ")"
      END

      //  IF cMsg <> NIL
      //     Tracelog( "GPF Intercepted!", cMsg )
      //     Alert( "GPF Intercepted!" + CRLF + cMsg )
      //  ENDIF
   ENDIF

   //  Throw( ErrorNew( "GPFHANDLER", 0, 0, ProcName(), "Erro de GPF", { cMsg, Exception, nCode }, Procfile(), Procname(), procline() ) )

   oError := ErrorNew( "GPFHANDLER", 0, 0, ProcName(), "Erro de GPF", { cMsg, Exception, nCode }, Procfile(), Procname(), procline() )

   ErrorDialog( oError )
   
Return EXCEPTION_EXECUTE_HANDLER

Eu uso em meus sistemas, espero que ajude,

[]´s

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...