shortyfw06 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to stop the execution of code when an error is found. I have "error" subroutines for example.
sub lam_num_error { $mw->messageBox(-message=>"The input must be an integer."); exit; }
The exit command is exiting the program completely which is not what I want. I've also tried this.
sub lam_num_error { $mw->messageBox(-message=>"The input must be an integer."); die; }
Using die seems to stop the execution of code but still keep the main window on the screen, which is what I want. However, I'm getting some errors like this.
Tk::Error: Died at Fastenator_working.pl line 1106. main::fl_num_error at Fastenator_working.pl line 1106 main::calc_fast_loads at Fastenator_working.pl line 1096 main::run_button at Fastenator_working.pl line 815 Tk callback for .frame13.button Tk::__ANON__ at C:/MSC.Software/Patran/2008_r2/Perl_msc/site/lib/Tk.p +m line 247 Tk::Button::butUp at C:/MSC.Software/Patran/2008_r2/Perl_msc/site/lib +/Tk/Button .pm line 111 <ButtonRelease-1> (command bound to event)
I'm not comfortable with these errors even though the code is still doing what I want. Can someone explain this and possibly suggest the best way to achieve my goal? I want the code to stop, let the user make some modifications to the input in the main window and then try again without completely shutting down the program. Thank you in advance!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Die vs. Exit
by davido (Cardinal) on Jul 20, 2012 at 20:34 UTC | |
by zentara (Archbishop) on Jul 20, 2012 at 21:03 UTC | |
Re: Die vs. Exit
by mbethke (Hermit) on Jul 20, 2012 at 20:05 UTC | |
Re: Die vs. Exit
by kcott (Archbishop) on Jul 20, 2012 at 21:54 UTC | |
by shortyfw06 (Beadle) on Jul 20, 2012 at 22:32 UTC | |
by shortyfw06 (Beadle) on Jul 20, 2012 at 23:14 UTC | |
by kcott (Archbishop) on Jul 21, 2012 at 01:02 UTC | |
Re: Die vs. Exit
by aitap (Curate) on Jul 20, 2012 at 20:13 UTC | |
Re: Die vs. Exit
by Anonymous Monk on Jul 21, 2012 at 03:15 UTC |