Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-06

procedure ShowException

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ondrej Pokorny

Hello,

is there any reason the OnShowException event is ignored for console applications?

Why not so:

procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
// use shortstring. On exception, the heap may be corrupt.
Var
   Buf : ShortString;
begin
SetLength(Buf,ExceptionErrorMessage(ExceptObject,ExceptAddr,@Buf[1],255));
   If Assigned(OnShowException) Then
     OnShowException (Buf)
   Else
   If IsConsole Then
     writeln(Buf)
end;

?

Ondrej

Reply by email

Sven Barth
to Ondrej Pokorny
Ondrej Pokorny wrote
Hello, is there any reason the OnShowException event is ignored for console applications?

The OnShowException event is a feature of FPC (Delphi doesn't have it), so whoever added it probably thought that it makes more sense this way 🤷‍♀️

Show quoted text 16 lines
Why not so: procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer); // use shortstring. On exception, the heap may be corrupt. Var   Buf : ShortString; begin SetLength(Buf,ExceptionErrorMessage(ExceptObject,ExceptAddr,@Buf[1],255));   If Assigned(OnShowException) Then     OnShowException (Buf)   Else   If IsConsole Then     writeln(Buf) end;

If no one objects I'd be inclined to swap it around this way. 😊

Regards,
Sven

Reply by email