FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TRY ... CATCH ... END
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
TRY ... CATCH ... END
Posted: Fri Dec 12, 2014 05:58 PM
Hello,

I have a very big dialogbox with lot's of function, use of very complicated arrays etc.

If an error in an array occurs, an errormessage is displayed and the application is quit.

So I tried to avoid the errormessage by using TRY ... CATCH ... END.

My code looks like :
Code (fw): Select all Collapse
TRY
     DEFINE DIALOG BOX oDlg .....
     REDEFINE GET .....
     REDEFINE LISTBOX ........
     REDEFINE BUTTON ........
     REDEFINE BUTTON ........
     ACTIVATE DIALOG .......
CATCH
     MsgAlert("An error occured but the dialog will be reopened automatically")
     oDlg:End()
END
If I make my code like this, my application is hanging if an error occurs.

If I don't use TRY ... CATCH ... END, the errormessage is displayed.

What do I do wrong?

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: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TRY ... CATCH ... END
Posted: Fri Dec 12, 2014 09:10 PM

Michel,

can I see a real sample that stops with error?

EMG

Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: TRY ... CATCH ... END
Posted: Sat Dec 13, 2014 01:48 AM
Hi Michel,

on your catch...end clause, test if oDlg is not NIL before you do oDlg:End().. anyway the error could be prior to that call.
In my experience with xHarbour, i put another try..catch..end on init function..

like:

Code (fw): Select all Collapse
TRY
    ..
    define dialog...
    ...
    activate dialog
    on init uInitiation()
    ...
CATCH
END

...

static function uInitiation()
TRY
   ...
CATCH
END
return
Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: TRY ... CATCH ... END
Posted: Sat Dec 13, 2014 06:52 PM

I think it would be better to find out why the error is occurring and fix it.

What is the error message? Can you tell which line it is occurring on? If so, can we see the code for that line?

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: TRY ... CATCH ... END
Posted: Mon Dec 15, 2014 04:55 PM
Code (fw): Select all Collapse
TRY
     DEFINE DIALOG BOX oDlg .....
     REDEFINE GET .....
     REDEFINE LISTBOX ........
     REDEFINE BUTTON ........
     REDEFINE BUTTON ........
     ACTIVATE DIALOG .......
CATCH
     MsgAlert("An error occured but the dialog will be reopened automatically")
     If ValType(oDlg) == "O"
          oDlg:End()
     End
END


James Bott wrote:I think it would be better to find out why the error is occurring and fix it.
2
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2

Continue the discussion