Zeos/Firebird Exception Handling lazarus / 16-Databases ---------------------------------------------------------------------- dogriz · 2014-01-25 14:00 Is there a way to handle Firebird Exception message in Lazarus? ZEOS 7.1.2 Firebird 2.5.2 Lazarus 1.0.xx ---------------------------------------------------------------------- mangakissa · 2014-01-26 14:56 The most datacomponments has the following events. - OnDeleteError - OnPosterror - OnInsertError  Sometimes (SQBdb has) OnUpdateError ---------------------------------------------------------------------- sin_dragan · 2014-01-27 20:23 Hi i use this with SqlDB, I think you can do the same with Zeos: Code: [Select]with dmCv.MestaQ do     begin       if Izmena then MestoID := Fields[0].AsInteger;       Close;       if Izmena then       begin         SQL := UpdateSQL;         Params[2].AsInteger := MestoID;       end       else SQL := InsertSQL;       Params[0].AsString := edtNazivMesta.Text;       Params[1].AsString := mmKomentarMesta.Text;       ExecSQL;       dmCv.FBTran.Commit;     end;   except     on E: EIBDatabaseError do     begin       case E.GDSErrorCode of       335544665 : ShowMessage('Mesto ' + edtNazivMesta.Text + ' već postoji u bazi.'); //record already exist in DB       else         ShowMessage('Greška u radu sa bazom podataka, pozovite IT službu!');         Close;       end;     end; //or with Zeos procedure TForm1.Button1Click(Sender: TObject); begin   try   ZQuery1.ExecSQL;   ZQuery1.Open;   except     on E:EZSQLException do       ShowMessage('sql error code' + inttostr(e.ErrorCode) + sLineBreak +e.Message);   end; end; ---------------------------------------------------------------------- dogriz · 2014-01-27 21:16 Actually, I want to catch exception message like the one in employee database. For example, in employee database there are a few exceptions defined (CUSTOMER_CHECK, CUSTOMER_ON_HOLD...) and I want to catch exception message string ("Overdue balance -- can not ship."). Simple use of try except on E: Exception doesn't give me the message I want. And, btw, which version of ZEOS has E:EZSQLException? ---------------------------------------------------------------------- sin_dragan · 2014-01-27 23:21 Try this, it's not a perfect solution but it could serve you. In ZDbcInterbase6Utils.pas line 814 change to ErrorMessage := ErrorMessage + '|' + String(Msg); Rebuild clean Zeos package. Add Zstoredproc. Code: [Select]procedure TForm1.Button1Click(Sender: TObject); var   SL: TStringList; begin   try   sl := TStringList.Create;   ZStoredProc1.StoredProcName := 'SHIP_ORDER';   ZStoredProc1.Params[0].AsString := 'V93N5822';   ZStoredProc1.ExecProc;   except     on E:EZSQLException do     begin       sl.Delimiter := '|';       sl.StrictDelimiter := true;       sl.DelimitedText := E.Message;       ShowMessage(sl[3]);     end;   end; end; ---------------------------------------------------------------------- dogriz · 2014-01-28 09:34 Quote from: sin_dragan on January 28, 2014, 12:21:37 amTry this, it's not a perfect solution but it could serve you. In ZDbcInterbase6Utils.pas line 814 change to ErrorMessage := ErrorMessage + '|' + String(Msg); Rebuild clean Zeos package. Add Zstoredproc. Code: [Select]procedure TForm1.Button1Click(Sender: TObject); var   SL: TStringList; begin   try   sl := TStringList.Create;   ZStoredProc1.StoredProcName := 'SHIP_ORDER';   ZStoredProc1.Params[0].AsString := 'V93N5822';   ZStoredProc1.ExecProc;   except     on E:EZSQLException do     begin       sl.Delimiter := '|';       sl.StrictDelimiter := true;       sl.DelimitedText := E.Message;       ShowMessage(sl[3]);     end;   end; end;                    I get this error: Quoteunit1.pas(45,10) Error: Identifier not found "EZSQLException" I use ZEOS 7.1.2-stable. ---------------------------------------------------------------------- sin_dragan · 2014-01-29 15:58 I also use 7.1.2-stable, add ZDbcIntfs to use list. You can try to read the full message from exception, I'll try to find a way to parse the message without the need to modify zeos source.