procedure MessageException(E: Exception); var TI: TypInfo.PTypeInfo; begin TI := E.ClassInfo; if Assigned(TI) then begin Dialogs.MessageDlg(TypInfo.GetTypeData(TI).UnitName + '.' + E.ClassName + ': ' + E.Message, Dialogs.mtError, [Dialogs.mbOK], 0, Dialogs.mbOK); end else begin Dialogs.MessageDlg(E.ClassName + ': ' + E.Message, Dialogs.mtError, [Dialogs.mbOK], 0, Dialogs.mbOK); end; end;
Note that ClassInfo must be tested for nil . For instance. SysUtils.ERangeError does not have this.
source share