On Mon, 16 Aug 2021 at 17:51, Jonathan Wakely <jwakely....@gmail.com> wrote:
>
> On Mon, 16 Aug 2021 at 13:11, Jonathan Wakely <jwakely....@gmail.com> wrote:
> >
> >
> >
> > On Mon, 16 Aug 2021, 12:55 Jonathan Wakely, <jwakely....@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.
>
> Here's what I plan to commit. It just uses {"generic": EACCES} for
> known categories that use errno values, and {"foo": 99} for other
> error categories.
>
>
> It also supports std::error_condition (using the same printer and the
> same output formats).

Actually, the proposal in PR 65230 would mean that we should print { }
if the object has its default-constructed state, i.e. {"system": 0}
for error_code and {"generic": 0} for error_condition. I'll make that
change before pushing anything to master.

Other suggestions for improvement (or just agreeing with the
direction) are welcome.

Reply via email to