Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Why can't I catch the exception?

Posted on 2004-08-04
2
Medium Priority
?
190 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

721 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