Solved

Why can't I catch the exception?

Posted on 2004-08-04
2
183 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

948 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now