Forum > LCL

How to Show the name of the exception

(1/1)

BlueIcaro:
Hello, I making some test with exceptions
I did this test program

--- 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";}};} --- unit Unit1 ;  {$mode objfpc}{$H+} interface uses  Classes ,SysUtils ,FileUtil ,Forms ,Controls ,Graphics ,Dialogs ,StdCtrls ; Type MiError = Class (Exception); type   { TForm1 }   TForm1 = class(TForm )    Button1 :TButton ;    Edit1 :TEdit ;    procedure Button1Click (Sender :TObject );  private    { private declarations }  Procedure MiPrueba;  public    { public declarations }  end;  var  Form1 : TForm1 ;  implementation {$R *.lfm} { TForm1 } procedure TForm1 .Button1Click (Sender :TObject );begin Try   MiPrueba; Except   On MiError do   ShowMessage ('Error mio');   Else    ShowMessage (Exception.Message); //Show the "generic" exception end;end; procedure TForm1 .MiPrueba ;begin   IF (StrToInt (Edit1.Text)) = 1 Then  Begin    Raise MiError.Create('Mi Error');  end;end; end.              
Well, I want to show the name of the "generic" exception, where I have the showMessage

Thanks

/BlueIcaro

Leledumbo:

--- Code: Delphi  [+][-]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  .. // something badexcept  on e: Exception do    ShowMessage(e.ClassName);end; 

BlueIcaro:
Thank you, Leledumbo, it's works  :)

/BlueIcaro

Navigation

[0] Message Index

Go to full version