FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Question about TRY ... CATCH ... END
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about TRY ... CATCH ... END
Posted: Thu Nov 13, 2008 11:33 AM

Hello,

A question about TRY ... CATCH ... END.

By using this function, one can prevent an error to be happening.

But that also means that no error.log is being made.

Is there a possibility to combine both cases, i.e. making an error.log while using TRY ... CATCH ... END ?

Thanks a lot for any help.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Question about TRY ... CATCH ... END
Posted: Thu Nov 13, 2008 12:18 PM
Michel,

you can decide for your own in the catch statement what to do with the error.

LOCAL  oErr

  TRY
    <do_something>
  CATCH oErr
    if oErr:gencode = ....
      WriteLogFile (oErr:description)
    endif
  END
kind regards

Stefan
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about TRY ... CATCH ... END
Posted: Thu Nov 13, 2008 01:42 PM

Stefan,

Thanks for your reaction, but I notice some problems.

  1. I got an error "no exported method : gencode"
  2. I got an error while linking : "Unresolved external symbol : hb_fun_writelogfile".

What now ?

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Question about TRY ... CATCH ... END
Posted: Thu Nov 13, 2008 01:56 PM
Michel,

With the CATCH, you can use they properties for your error safety:
TRY
   ...
CATCH oError

   msgInfo( oError:SubSystem )
   msgInfo( oError:SubCode )
   msgInfo( oError:Operation )
   msgInfo( oError:Description )
   msgInfo( valToPrg( ::oError:Args ) )

END

With they properties, you can generate you own "err.log" or many others things!!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Question about TRY ... CATCH ... END
Posted: Thu Nov 13, 2008 03:46 PM

Michel,

Use LogFile() instead of WriteLogFile().

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Question about TRY ... CATCH ... END
Posted: Thu Nov 13, 2008 04:12 PM
Michel,

driessen wrote:
1. I got an error "no exported method : gencode"
2. I got an error while linking : "Unresolved external symbol : hb_fun_writelogfile".


oErr:gencode is working here, it´s defined in the errorhandler of xharbour and it´s also working in errorsysw.prg from fwh.

The function WriteLogFile() was just a sample, not a really existing function. Just to show what you can do.

Please try this sample, it´s working fine here. (see also JC´s post)

//----------------------------------------------------------------------------//
FUNCTION CheckErr ()

  LOCAL nLoc, oError

  TRY
    nLoc := "error"/2
  CATCH oError
    msgInfo( oError:gencode )
    msgInfo( oError:SubSystem )
    msgInfo( oError:SubCode )
    msgInfo( oError:Operation )
    msgInfo( oError:Description )
    msgInfo( valToPrg( oError:Args ) )
    quit
  END

RETURN (nLoc)


There are some other values that can be checked, oError:severity, oError:tries, oError:oscode and so on.
kind regards

Stefan
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about TRY ... CATCH ... END
Posted: Thu Nov 13, 2008 05:03 PM

Thanks guys, for your help.

I know what to do now.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion