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


(Core :: Internationalization, task, P3)




94 Branch
Tracking Status
firefox94 --- fixed


(Reporter: gregtatum, Assigned: gregtatum)


(Blocks 1 open bug)


(Whiteboard: [i18n-unification])


(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
Use ICUError in mozilla::intl::Calendar; r=platform-i18n-reviewers,dminor
Use ICUError in mozilla::intl::DateTimePatternGenerator; r=platform-i18n-reviewers,dminor
Use ICUError in mozilla::intl::PluralRules; r=platform-i18n-reviewers,dminor
Add missing ICUError.h headers; r=platform-i18n-reviewers,dminor
Flatten nested namespaces in mozilla::intl components; r=platform-i18n-reviewers,dminor
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.