Skip to content
Merged
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
41 changes: 41 additions & 0 deletions rust/catalyst-types/src/problem_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ enum Kind {
/// Explanation of the failed or problematic validation
explanation: String,
},
/// Duplicate field was detected.
DuplicateField {
/// The duplicated field.
field: String,
/// Additional information about the duplicate field.
description: String,
},
/// An uncategorized problem was encountered. Use only for rare problems, otherwise
/// make a new problem kind.
Other {
Expand Down Expand Up @@ -337,6 +344,40 @@ impl ProblemReport {
);
}

/// Reports that duplicate field was detected in the problem report.
///
/// This method adds an entry to the problem report indicating that duplicate field
/// is found, along with the description of the duplicate field and any additional
/// context.
///
/// # Arguments
///
/// * `field`: A string slice representing the value of the duplicate field.
/// * `description`: An additional information about the duplicate field.
/// * `context`: A string slice providing additional context or information about
/// where and why this duplicate field was detected.
///
/// # Example
///
/// ```rust
/// # use catalyst_types::problem_report::ProblemReport;
/// let report = ProblemReport::new("RBAC Registration Decoding");
/// report.duplicate_field(
/// "key 0",
/// "key is already defined, redundant key found in item 6 in RBAC map",
/// "RBAC purpose",
/// );
/// ```
pub fn duplicate_field(&self, field: &str, description: &str, context: &str) {
self.add_entry(
Kind::DuplicateField {
field: field.to_owned(),
description: description.to_owned(),
},
context,
);
}

/// Reports an uncategorized problem with the given description and context.
///
/// This method is intended for use in rare situations where a specific type of
Expand Down
Loading