Closed Bug 1713206 Opened 5 months ago Closed 1 month ago

Simplify the errors used in mozilla::intl APIs, and ensure they pack nicely in a Result

Categories

(Core :: Internationalization, task, P3)

task

Tracking

()

RESOLVED FIXED
94 Branch
Tracking Status
firefox94 --- fixed

People

(Reporter: gregtatum, Assigned: gregtatum)

References

(Blocks 1 open bug)

Details

(Whiteboard: [i18n-unification])

Attachments

(6 files)

Currently there is lots of duplication in the error types returned by the unified intl APIs. We should take a pass across the components and unify them into a simpler set. In addition, we should try and ensure that we don't need to use the ResultVariant.h file. I filed these two bugs together because they seem like they could be handled in a single pass.

per anba:

Packed-variant selection happens here.

class DateTimeFormat final {
  // ...

  // Start error values at 1 to allow using the UnusedZero Result optimization.
  enum class StyleError { DateFormatFailure = 1 };

  // ...
};

namespace mozilla::detail {
template <>
struct UnusedZero<DateTimeFormat::StyleError> : UnusedZeroEnum<DateTimeFormat::StyleError> {};
}

We should also make sure the errors are defined in a separate header, and remove the error definitions from ICU4CGlue.h, since this work may outlive our use of ICU4C.

Whiteboard: [i18n-unification]
Assignee: nobody → gtatum

I don't think we can get rid of the ResultVariant.h. In order to be a PackedVariant, it must fit into:

  struct VEbool {
    V v;
    E e;
    bool ok;
  };

  struct EVbool {
    E e;
    V v;
    bool ok;
  };

Such that sizeof the struct is less than uintptr_t.

This is a drive-by clean-up while I'm working on errors.

Depends on D124962

Pushed by gtatum@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3b74133ec371
Use ICUError in mozilla::intl::Calendar; r=platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/7a671d2ad4f4
Use ICUError in mozilla::intl::DateTimePatternGenerator; r=platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/0791afd78546
Use ICUError in mozilla::intl::PluralRules; r=platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/8490468f29bf
Add missing ICUError.h headers; r=platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/1ca14b3b9c6e
Flatten nested namespaces in mozilla::intl components; r=platform-i18n-reviewers,dminor
https://hg.mozilla.org/integration/autoland/rev/8b89cbf78dfd
Propagate ICU statuses to ICUErrors; r=platform-i18n-reviewers,dminor
Blocks: 1730508
You need to log in before you can comment on or make changes to this bug.