Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions cedar-policy-core/src/parser/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,6 @@ impl ParseErrors {
pub(super) fn push(&mut self, err: impl Into<ParseError>) {
self.0.push(err.into());
}

/// returns a Vec with stringified versions of the ParseErrors
pub fn errors_as_strings(&self) -> Vec<String> {
self.0.iter().map(ToString::to_string).collect()
}
}

impl Display for ParseErrors {
Expand Down
4 changes: 4 additions & 0 deletions cedar-policy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
in an internal crate, allowing us to make semver incompatible changes. (#857)
- Removed the (deprecated) `frontend` module in favor of the new `ffi` module
introduced in 3.2.0. See #757.
- Removed `ParseErrors::errors_as_strings`. Callers should consider examining
the rich data provided by `miette::Diagnostic`, for instance `.help()` and
`labels()`. Callers can continue using the same behavior by calling
`.iter().map(ToString::to_string)`. (#882, resolving #543)

## [3.2.0] - Coming Soon

Expand Down
3 changes: 1 addition & 2 deletions cedar-testing/tests/cedar-policy-cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ fn perform_integration_test_from_json(jsonfile: impl AsRef<Path>) {
);
assert!(
parse_errs
.errors_as_strings()
.iter()
.any(|s| s.ends_with("not a function")),
.any(|e| e.to_string().ends_with("not a function")),
"unexpected parse errors in test {}: {}",
jsonfile.display(),
parse_errs,
Expand Down
6 changes: 3 additions & 3 deletions cedar-wasm/src/policies_and_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn policy_text_to_json(cedar_str: &str) -> PolicyToJsonResult {
match parse_policy_or_template_to_est(cedar_str) {
Ok(policy) => PolicyToJsonResult::Success { policy },
Err(err) => PolicyToJsonResult::Error {
errors: err.errors_as_strings(),
errors: err.iter().map(ToString::to_string).collect(),
},
}
}
Expand All @@ -97,7 +97,7 @@ pub enum CheckParsePolicySetResult {
pub fn check_parse_policy_set(input_policies_str: &str) -> CheckParsePolicySetResult {
match PolicySet::from_str(input_policies_str) {
Err(parse_errors) => CheckParsePolicySetResult::Error {
errors: parse_errors.errors_as_strings(),
errors: parse_errors.iter().map(ToString::to_string).collect(),
},
Ok(policy_set) => {
let policies_count: Result<i32, <i32 as TryFrom<usize>>::Error> =
Expand Down Expand Up @@ -132,7 +132,7 @@ pub enum CheckParseTemplateResult {
pub fn check_parse_template(template_str: &str) -> CheckParseTemplateResult {
match Template::from_str(template_str) {
Err(parse_errs) => CheckParseTemplateResult::Error {
errors: parse_errs.errors_as_strings(),
errors: parse_errs.iter().map(ToString::to_string).collect(),
},
Ok(template) => match template.slots().count() {
1 | 2 => CheckParseTemplateResult::Success {
Expand Down