Solved

Why can't I catch the exception?

Posted on 2004-08-04
2
189 Views
Last Modified: 2010-04-05
The following is my program. I would like to catch the exception from Test:=StrToInt('ss'). It still shows an EConvertError, Why can't I catch it?

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure MyExceptionHandler(Sender : TObject; E : Exception );
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
     { begin new code }
     Application.OnException:=MyExceptionHandler;
     { end new code }
end;

procedure TForm1.MyExceptionHandler(Sender : TObject; E : Exception );
var
     wRetVal : Word;
begin
     wRetVal := MessageDlg('ERROR: ' + E.Message, mtError, mbAbortRetryIgnore, 0 );
     case wRetVal of
         mrAbort: begin
             { handle "Abort" here... }
         end;
         mrRetry: begin
             { handle "Retry" here... }
         end;
         mrIgnore: begin
             { handle "Ignore" here... }
         end;
         else
         begin
             { handle "other" action here...}
         end;
     end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var Test:integer;
begin
   Test:=StrToInt('ss');
end;

end.
0
Comment
Question by:adamy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
LRHGuy earned 50 total points
ID: 11717363
I tried it, and it seems to catch it for me...but while in the DELPHI IDE, the debugger catches it first. When I turned off the integrated debugging (in options) it worked as expected...

Larry
0
 
LVL 1

Author Comment

by:adamy
ID: 11717995
Thanks a lot
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month4 days, 15 hours left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question