[fpc-devel] EInOutError constructor

Michael Van Canneyt michael at freepascal.org
Wed Jul 1 15:59:09 CEST 2026



On Wed, 1 Jul 2026, Bart via fpc-devel wrote:

> 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.


More information about the fpc-devel mailing list