Problem with try and except lazarus / 13-General ---------------------------------------------------------------------- josss · 2005-07-30 10:55 Hi. I'm a beginer with Lazarus/Delphi. I'm trying this code, and I want to show my own message saying 'Error', but the program stop with a general error advice like if my try/except construction don't exist (the compiler ignore it). What is that I'm doing wrong? Thanks. procedure TForm1.Button1Click(Sender: TObject); var   a ,b : integer;   c : real; begin   Try     a:=1;     b:=0;     c:=a/b;   except     on e : Exception do showmessage('Error');     end; end; ---------------------------------------------------------------------- Anonymous · 2005-07-31 10:47 If you add the line ShowMessage(FloatToStr(c)); immediately before the 'except' line I think you will see the answer. Floating point division apparently doesn't throw a divide-by-zero error, but correctly returns the answer - infinity! (This is a new one on me, I must say.) Eric ---------------------------------------------------------------------- eric · 2005-07-31 10:51 Sorry, the above was by me - I hadn't realised that my login had expired. Eric ---------------------------------------------------------------------- josss · 2005-07-31 17:40 what I mean is that don't work correctly exceptions handling. For example:     try       FechaAux:=StrtoDate(Fecha);     except       on E : Exception do begin         Result:=false;         ShowMessage('Error');         Exit;         end; //de On E : Exception       end; //de try never shows 'Error' altough Fecha is not a valid Date (like 'm' for example), or:     try       dbfAux.Open; //Se intenta abrir la base de datos     except       ShowMessage('Error al abrir la base de datos. El programa finalizará');       dbfAux.Free;       end; //de try where dbfAux is a TDbf object, never show 'Error al abrir la base de datos...' when the database doesn't exist. Instead, the program shows standard error and ends. ---------------------------------------------------------------------- glober · 2005-08-01 03:02 Regarding the StrToDate() function exeption handling, there was a bug : http://www.freepascal.org/bugs/showrec.php3?ID=3913 , which is fixed in the   current SVN FPC 2.0.1 version. If you have a previous version the problem is still there, so that isn't the best for testing exceptions. Sorry, don't know about  dbfAux.Open , maybe there is a bug on that one too.