Skip to content

Commit 835e6e5

Browse files
committed
fix(catalyst-types): add duplicate field description and change name
Signed-off-by: bkioshn <[email protected]>
1 parent ba3b41e commit 835e6e5

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

rust/catalyst-types/src/problem_report.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ enum Kind {
4848
/// Explanation of the failed or problematic validation
4949
explanation: String,
5050
},
51-
/// Duplicate data was detected.
52-
DuplicateData {
53-
/// The detected duplicate value.
54-
value: String,
51+
/// Duplicate field was detected.
52+
DuplicateField {
53+
/// The duplicated field.
54+
field: String,
55+
/// Additional information about the duplicate field.
56+
description: String,
5557
},
5658
/// An uncategorized problem was encountered. Use only for rare problems, otherwise
5759
/// make a new problem kind.
@@ -342,28 +344,35 @@ impl ProblemReport {
342344
);
343345
}
344346

345-
/// Reports that duplicate data was detected in the problem report.
347+
/// Reports that duplicate field was detected in the problem report.
346348
///
347-
/// This method adds an entry to the problem report indicating that duplicate data
348-
/// is found, along with the value of the duplicate data and any additional context.
349+
/// This method adds an entry to the problem report indicating that duplicate field
350+
/// is found, along with the description of the duplicate field and any additional
351+
/// context.
349352
///
350353
/// # Arguments
351354
///
352-
/// * `value`: A string slice representing the value of the duplicate data.
355+
/// * `field`: A string slice representing the value of the duplicate field.
356+
/// * `description`: An additional information about the duplicate field.
353357
/// * `context`: A string slice providing additional context or information about
354-
/// where and why this duplicate data was detected.
358+
/// where and why this duplicate field was detected.
355359
///
356360
/// # Example
357361
///
358362
/// ```rust
359363
/// use catalyst_types::problem_report::ProblemReport;
360364
/// let report = ProblemReport::new("RBAC Registration Decoding");
361-
/// report.duplicate_data("RBAC Purpose key at item 6 in map", "0");
365+
/// report.duplicate_field(
366+
/// "key 0",
367+
/// "key is already defined, redundant key found in item 6 in RBAC map",
368+
/// "RBAC purpose",
369+
/// );
362370
/// ```
363-
pub fn duplicate_data(&self, value: &str, context: &str) {
371+
pub fn duplicate_field(&self, field: &str, description: &str, context: &str) {
364372
self.add_entry(
365-
Kind::DuplicateData {
366-
value: value.to_owned(),
373+
Kind::DuplicateField {
374+
field: field.to_owned(),
375+
description: description.to_owned(),
367376
},
368377
context,
369378
);

0 commit comments

Comments
 (0)