Sign in Join

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

Mailing lists / fpc-devel / 2026-07

EInOutError constructor

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Bart

Hi,

EInOutError has a public property ErrorCode: Integer. There is however no constructor overload that lets you set ErrorCode, so that one could do:
raise EInOutError.Create('Message, Code).
So, now you have to do something like:

      E:=EInOutError.Create(SCannotCreateEmptyDir);
      E.ErrorCode:=3;
      Raise E;

Setting ErrorCode is nice for applications that want to show their own errormessages in reaction to an EInOutError exception, so you don't have to rely on the Message part to know what went wrong.

I noticed that EVariantError indeed has a constructor that llows to set it's ErrCode field in the constructor.

Would a feature request for such a constructor overlaod for EInOutError be considered as possibly viable?
(If at all possible I'ld like to overload the CreateFmt() versions as well.)

Bart

Reply by email

Michael Van Canneyt
to Bart
Bart wrote 22 lines
Hi, EInOutError has a public property ErrorCode: Integer. There is however no constructor overload that lets you set ErrorCode, so that one could do: raise EInOutError.Create('Message, Code). So, now you have to do something like: E:=EInOutError.Create(SCannotCreateEmptyDir); E.ErrorCode:=3; Raise E; Setting ErrorCode is nice for applications that want to show their own errormessages in reaction to an EInOutError exception, so you don't have to rely on the Message part to know what went wrong. I noticed that EVariantError indeed has a constructor that llows to set it's ErrCode field in the constructor. Would a feature request for such a constructor overlaod for EInOutError be considered as possibly viable? (If at all possible I'ld like to overload the CreateFmt() versions as well.)

I see no reason why we could not add an overloaded constructor...

Michael.

Reply by email