This is an archive of the discontinued LLVM Phabricator instance.

[libc++][format] Improve an exception message.
ClosedPublic

Authored by Mordante on Jan 2 2022, 8:06 AM.

Details

Summary

The fix in D116381 makes an existing exception message wrong. This
improves the message and fixes the associated unit tests.

Note other message can be also be improved, but that will be done later.
Changing these messages may cause merge conflicts with other patches
that are under review or WIP.

Depends on D116381

Diff Detail

Event Timeline

Mordante requested review of this revision.Jan 2 2022, 8:06 AM
Mordante created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 2 2022, 8:06 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Quuxplusone added a subscriber: Quuxplusone.

Seems fine to me!

ldionne added a subscriber: ldionne.Jan 3 2022, 1:31 PM

I'm a bit confused -- I thought the error messages was supposed to mention that the arg-id shouldn't have leading zeros?

This as a generic message error message and a leading zero is one of the possible errors. As you can see in the tests it also rejects {9a, {9:. I don't think it's useful to add an extra code path to add more details for the exact error. There's also no specific error for {1 at the end of input. Do you think it's useful to show the expected format? Something along the lines of "Arg-id doesn't match {(0|[1-9][0-9]*)}".

ldionne accepted this revision.Jan 4 2022, 10:10 AM

LGTM but I think it would be worth looking into whether we can improve all error messages, independently. IIUC this is at least an improvement in that it makes the error messages "not lie".

This revision is now accepted and ready to land.Jan 4 2022, 10:10 AM
Mordante updated this revision to Diff 397499.Jan 5 2022, 3:32 AM

Rebased to poke CI.

This revision was automatically updated to reflect the committed changes.