What should a std::error_code pretty printer show?
Jonathan Wakely
jwakely.gcc@gmail.com
Mon Aug 16 12:11:18 GMT 2021
On Mon, 16 Aug 2021, 12:55 Jonathan Wakely, <jwakely.gcc@gmail.com> wrote:
> I'm adding a GDB printer for std::error_code.What I have now prints
> the category name as a quoted string, followed by the error value:
>
> {"system": 0}
> {"system": 1234}
>
> If the category is std::generic_category() then it also shows the
> strerror description:
>
I should probably extend this special case for the generic category to also
apply to the system category when the OS is POSIX-based. For POSIX systems,
the system error numbers are generic errno values.
> {"generic": 13 "Permission denied"}
>
> But I'd also like it to show the errno macro, but I'm not sure what's
> the best way to show it.
>
> Does this seem OK?
>
> {"generic": 13 EACCES "Permission denied"}
>
> I think that's a bit too verbose.
>
> Would {"generic": EACCES} be better? You can always use ec.value() to
> get the numeric value, and strerror to get the description if you want
> those.
>
More information about the Libstdc++
mailing list