@@ -55,6 +55,15 @@ enum Kind {
5555 /// Additional information about the duplicate field.
5656 description : String ,
5757 } ,
58+ /// Conversion error.
59+ ConversionError {
60+ /// The field that failed to convert
61+ field : String ,
62+ /// The value that failed to convert
63+ value : String ,
64+ /// The type that the value was expected to convert to
65+ expected_type : String ,
66+ } ,
5867 /// An uncategorized problem was encountered. Use only for rare problems, otherwise
5968 /// make a new problem kind.
6069 Other {
@@ -378,6 +387,42 @@ impl ProblemReport {
378387 ) ;
379388 }
380389
390+ /// Reports a conversion error.
391+ ///
392+ /// This method adds an entry to the problem report indicating that a field failed to
393+ /// convert to the expected type, along with the value that failed to convert and
394+ /// the expected type.
395+ ///
396+ /// # Arguments
397+ ///
398+ /// * `field`: A string slice representing the field that failed to convert.
399+ /// * `value`: A string slice representing the value that failed to convert.
400+ /// * `expected_type`: A string slice representing the type that the value was
401+ /// expected to convert to.
402+ ///
403+ /// # Example
404+ ///
405+ /// ```rust
406+ /// use catalyst_types::problem_report::ProblemReport;
407+ /// let report = ProblemReport::new("RBAC Registration Decoding");
408+ /// report.conversion_error(
409+ /// "address bytes",
410+ /// "[1, 2, 3, 4]",
411+ /// "Address",
412+ /// "RBAC stake address",
413+ /// );
414+ /// ```
415+ pub fn conversion_error ( & self , field : & str , value : & str , expected_type : & str , context : & str ) {
416+ self . add_entry (
417+ Kind :: ConversionError {
418+ field : field. to_owned ( ) ,
419+ value : value. to_owned ( ) ,
420+ expected_type : expected_type. to_owned ( ) ,
421+ } ,
422+ context,
423+ ) ;
424+ }
425+
381426 /// Reports an uncategorized problem with the given description and context.
382427 ///
383428 /// This method is intended for use in rare situations where a specific type of
0 commit comments