Forum > Databases

Error Firebird in Lazarus

(1/2) > >>

calm_sea:
Hi everyone. I can't find a way to catch firebird errors from lazarus. With IBEventMonitor I can acquire the errorcode but I can't get the string of the error.

rvk:

--- Quote from: calm_sea on February 23, 2023, 12:03:39 pm ---Hi everyone. I can't find a way to catch firebird errors from lazarus. With IBEventMonitor I can acquire the errorcode but I can't get the string of the error.

--- End quote ---
Can't you just use the try/except handling?

It depends on the components used but if you use IBX.

With the normal Exception:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---try  // do your thing with SQLexcept  on E: Exception do  begin    // your generic message is in E.Message    if (E is EIBInterBaseError) then    begin      // your errorcode is in EIBInterBaseError(E).IBErrorCode      // and sqlcode is in EIBInterBaseError(E).SQLCode    end;  end;end;
If you only need to catch the EIBInterBaseError then you can do this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---try  // do your thing with SQLexcept  on E: EIBInterBaseError do  begin    // your errorcode is in EIBInterBaseError(E).IBErrorCode    // and sqlcode is in EIBInterBaseError(E).SQLCode  end;end;
Other exceptions will pass through to the caller function.

calm_sea:
Yes, thanks. I was wondering if it's possible to centralize error handling across the whole db, not at the level of each specific query. I had thought that with IBEventManager it was possible, but I can't do it

rvk:

--- Quote from: calm_sea on February 23, 2023, 02:54:14 pm ---Yes, thanks. I was wondering if it's possible to centralize error handling across the whole db, not at the level of each specific query. I had thought that with IBEventManager it was possible, but I can't do it

--- End quote ---
No, not that I'm aware of.

It wouldn't make sense to me because every part of your program (and DB handling) could require it's own special handling.
If that's not the case you can just let the exception happen and handle it with the Application.OnException (you can write your own generic exception handler).

calm_sea:
OK thank you! One last thing. How can I get firebird error messages in Italian? Is there a firebird.msg file in Italian?

Navigation

[0] Message Index

[#] Next page

Go to full version