catch TOpenGLContext exceptions lazarus / 70-OpenGL ---------------------------------------------------------------------- apeoperaio · 2016-02-19 10:45 I developed an application using TOpenGLcontext. Some users have problems with opengl (especially on linux), missing libraries, FB config missing and so on. Actually if the system on which my application is running has problems with opengl my app crashes. e.g.: "Could not find FB config" Press OK to ignore and risk data corruption Press Cancel to kill the program I would like to catch these exceptions and if Topenglcontext cannot work I would like to disable it and run my app wihout it. How can I do it? Thanks. Andrea ---------------------------------------------------------------------- balazsszekely · 2016-02-19 11:04 You should debug the code and find out which line causing the exception. To handle all exception on application level, switch do release mode, then do this on the main form: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i //... TForm1 = class(TForm)    procedure FormCreate(Sender: TObject);  private    procedure HandleExceptions(Sender: TObject; E: Exception);    { private declarations }  public    { public declarations }  end;       //...procedure TForm1.FormCreate(Sender: TObject);begin  Application.OnException := @HandleExceptions;end; procedure TForm1.HandleExceptions(Sender: TObject; E: Exception);begin  //handle here --> show something or not, it's up to you  ShowMessage(E.Message); end; ---------------------------------------------------------------------- apeoperaio · 2016-02-19 11:16 I cannot find where the exception is raised exactly since I am not able to reproduce the problem. Anyway I just want to not create the TOpenGLContext if OpenGL are not working. I have a TOpenGLContext on my main form (design time), I would like to catch exceptions related ONLY to opengl and eventually disable in some way the openglcontext and run my application without using TOpenGLContext. I can create TOpenGLContext at runtime after a test that guarantee me that TOpenGLContext will run. I want to avoid unexpected crash related to opengl. Something like try   Ok:= TestIFTOpenGLContextCanRun; except   messageerror; end; if Ok then   CreateTOpengLContext; // run my app