Forum > General

[SOLVED] Exception not Handled

(1/1)

BenLaz:
Hello,

I've a strange comportment easily reproductible :

that code doesn't catch the exception and the application stop working

var
  r1 : Real;
begin
  try
    r1 := r1 / 0;
  except
    Beep;
  end;
end.   

Does any one have any idea ?

Ps : I use FPC 2.6.4 and Lazarus from svn trunc

marcov:
Make sure you  USES sysutils.

BenLaz:
It's the case either in my program and in the simple test program i made.

Here it is :

program Bug;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, sysutils;

var
  r1 : Real;
begin
  r1 := 1;
  try
    r1 := r1 / 0;
  except
    Beep;
  end;
end.   

ChrisF:
I guess you're trying to run your program inside the Lazarus IDE, aren't you ?

If it's the case, the most simple way to correct it is to run your program outside the IDE.

There are already some posts about this behavior (i.e. exceptions handling when running inside or outside the IDE ) in this forum.

** Edit ** One of these discussions:
http://forum.lazarus.freepascal.org/index.php/topic,24743.0.html

.

BenLaz:
Thank you very much for your answer,

You're right, when running outside of the debugger it just works fine. 

Navigation

[0] Message Index

Go to full version