Link to home
Start Free TrialLog in
Avatar of AbhiJeet
AbhiJeet

asked on

delphi exception

Hello Experts,
Procedure 1
try
    NewForm;
  except
    on E: Exception do
      .......................my code
        raise;
  end;

Part of NewForm is below:

try
      if not EOF then
        raise Exception.Create('This form already exists.'); // control from here goes to procedure 1
    finally
      Close;
    end;

The problem is when exception occurs, eureka log message comes up first which asks to restart the application hence i am not able to see the error message 'This form already exists'.

What to change, any idea please?
Avatar of odd lie
odd lie
Flag of Norway image

Is the form autocreated ?
you see the application.createform(Tnewform, Newform);
in the DPR (view source)
try changing in menu:
 project -> options -Forms

Regards Oldelphi
Avatar of Sinisa Vuk
....and use new/local variable for new form, not auto-generated one (aka Form1: TForm1)
Avatar of AbhiJeet
AbhiJeet

ASKER

it is not actually about form creation related error, lets say i write as below

Procedure 1
try
    NewUser;
  except
    on E: Exception do
      .......................my code
        raise;
  end;

Part of NewUser procedure is below:

try
      if not EOF then
        raise Exception.Create('This user already exists.'); // control from here goes to procedure 1
    finally
      Close;
    end;

i am searching in a table and if i find a record i am creating the exception. But i dont like the eureka log error, i need to see the error message as "user already exists"
You can set Exception filter
Another good tips.... (find: Q: I want to ignore particular exception. How can I do this?)
That may not help, as you see i am forcefully creating the exception when i find the record in a table.
Sinisa is pointing you to the right direction.
As you use EurekaLog, it brings up any exception even if you create your own by code, therefor what you have to do is to disable eurekalog before executing your table search and to re-enable it at the end. This way any exception created by you will be raised by your code without being handled by eurekalog
ASKER CERTIFIED SOLUTION
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial