Skip to content

Commit

Permalink
Cleaning up DataError (#5146)
Browse files Browse the repository at this point in the history
The variants are now:
* `MarkerNotFound`
* This was `MissingDataMarker`, unclear if it was missing from the
request or the data
* `IdentifierNotFound`
* This was `MissingLocale`, unclear if it was missing from the request
or the data, and needs to use identifier terminology
* ~`NeedsLocale`~
  * The locale is not optional, this was unused 
* `InvalidRequest`
* This was `ExtraneousLocale` but I think it should cover other illegal
requests as well
* `Filtered`
* This was `FilteredResource`, but we're not using resource terminology
anymore
* `InconsistentData`
* `Downcast`
* This was `MismatchedType`, but is only returned from
`AnyPayload::downcast` and `DowncastingAnyProvider`, so I think this is
a better name. Also more symmetric with ...
* `Deserialize`
* This was `UnavailableBufferFormat` or `Custom` before. Now all serde
issues return this variant, i.e. `DataPayload::deserialize` and
`DeserializingBufferProvider`
* `Custom`
* `Io`
* ~`MissingSourceData`~
* `DatagenProvider` is just one provider implementation, it can use
`Custom`
  • Loading branch information
robertbastian authored Jun 28, 2024
1 parent 798f06e commit b021268
Show file tree
Hide file tree
Showing 677 changed files with 904 additions and 919 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ macro_rules! __impl_date_skeleton_patterns_v1_marker {
break payload;
}
if fallback_iterator.get().is_und() {
return Err(icu_provider::DataErrorKind::MissingLocale.with_req(<icu::datetime::provider::calendar::DateSkeletonPatternsV1Marker as icu_provider::DataMarker>::INFO, req));
return Err(icu_provider::DataErrorKind::IdentifierNotFound.with_req(<icu::datetime::provider::calendar::DateSkeletonPatternsV1Marker as icu_provider::DataMarker>::INFO, req));
}
fallback_iterator.step();
}
Expand Down
5 changes: 2 additions & 3 deletions components/experimental/src/transliterate/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,8 @@ where
let Some((source, reverse, visible)) =
exclusive_data.0.remove(req.id.marker_attributes as &str)
else {
return Err(
DataErrorKind::MissingLocale.with_req(TransliteratorRulesV1Marker::INFO, req)
);
return Err(DataErrorKind::IdentifierNotFound
.with_req(TransliteratorRulesV1Marker::INFO, req));
};

let rules = parse::Parser::run(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/locale/src/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ mod tests {

println!("{:#?}", marker);
if self.markers.contains(&marker) {
return Err(DataErrorKind::MissingDataMarker.with_str_context("rejected"));
return Err(DataErrorKind::MarkerNotFound.with_str_context("rejected"));
}

let aliases_v2 = crate::provider::Baked::SINGLETON_ALIASES_V2_MARKER;
Expand Down Expand Up @@ -675,7 +675,7 @@ mod tests {
DataPayload::<LikelySubtagsForScriptRegionV1Marker>::from_static_ref(sr)
.wrap_into_any_payload()
} else {
return Err(DataErrorKind::MissingDataMarker.into_error());
return Err(DataErrorKind::MarkerNotFound.into_error());
};

Ok(AnyResponse {
Expand Down
4 changes: 2 additions & 2 deletions components/locale/src/expander.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ mod tests {
_: DataRequest,
) -> Result<AnyResponse, DataError> {
if self.markers.contains(&marker) {
return Err(DataErrorKind::MissingDataMarker.with_str_context("rejected"));
return Err(DataErrorKind::MarkerNotFound.with_str_context("rejected"));
}

let l = crate::provider::Baked::SINGLETON_LIKELY_SUBTAGS_FOR_LANGUAGE_V1_MARKER;
Expand Down Expand Up @@ -693,7 +693,7 @@ mod tests {
DataPayload::<LikelySubtagsForScriptRegionV1Marker>::from_static_ref(sr)
.wrap_into_any_payload()
} else {
return Err(DataErrorKind::MissingDataMarker.into_error());
return Err(DataErrorKind::MarkerNotFound.into_error());
};

Ok(AnyResponse {
Expand Down
2 changes: 1 addition & 1 deletion components/locale/src/fallback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl LocaleFallbacker {
Ok(response) => Some(response.payload),
// It is expected that not all keys are present
Err(DataError {
kind: DataErrorKind::MissingDataMarker,
kind: DataErrorKind::MarkerNotFound,
..
}) => None,
Err(e) => return Err(e),
Expand Down
2 changes: 1 addition & 1 deletion components/segmenter/src/complex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ fn try_load<M: DataMarker, P: DataProvider<M> + ?Sized>(
}) {
Ok(response) => Ok(Some(response.payload)),
Err(DataError {
kind: DataErrorKind::MissingLocale,
kind: DataErrorKind::IdentifierNotFound,
..
}) => Ok(None),
Err(e) => Err(e),
Expand Down
19 changes: 9 additions & 10 deletions ffi/capi/bindings/c/ICU4XDataError.d.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 18 additions & 20 deletions ffi/capi/bindings/cpp/ICU4XDataError.d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions ffi/capi/bindings/cpp/ICU4XDataError.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions ffi/capi/bindings/dart/DataError.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ffi/capi/bindings/dart/DataProvider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions ffi/capi/bindings/js/ICU4XDataError.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 24 additions & 27 deletions ffi/capi/bindings/js/ICU4XDataError.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ffi/capi/bindings/js/ICU4XDataProvider.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b021268

Please sign in to comment.