TRY ... CATCH ... END

TRY ... CATCH ... END

Postby driessen » Fri Dec 12, 2014 5: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: Select all  Expand view
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. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: TRY ... CATCH ... END

Postby Enrico Maria Giordano » Fri Dec 12, 2014 9:10 pm

Michel,

can I see a real sample that stops with error?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TRY ... CATCH ... END

Postby fraxzi » Sat Dec 13, 2014 1: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: Select all  Expand view

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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: TRY ... CATCH ... END

Postby James Bott » Sat Dec 13, 2014 6: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?
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: TRY ... CATCH ... END

Postby sambomb » Mon Dec 15, 2014 4:55 pm

Code: Select all  Expand view

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
MSN: SamirAbreu@hotmail.com
Skype: SamirAbreu
xHarbour 1.1.0 + FwXh 8.02
xHarbour 1.2.1 + Fwhh 10.6
User avatar
sambomb
 
Posts: 385
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 100 guests