1212// *******************************************************************************
1313extern crate alloc;
1414
15+ use crate :: log:: { error, ScoreDebug } ;
1516use alloc:: string:: FromUtf8Error ;
1617use core:: array:: TryFromSliceError ;
1718
1819/// Runtime Error Codes
19- #[ derive( Debug , PartialEq ) ]
20+ #[ derive( Debug , PartialEq , ScoreDebug ) ]
2021pub enum ErrorCode {
2122 /// Error that was not yet mapped
2223 UnmappedError ,
@@ -94,7 +95,7 @@ impl From<std::io::Error> for ErrorCode {
9495 match kind {
9596 std:: io:: ErrorKind :: NotFound => ErrorCode :: FileNotFound ,
9697 _ => {
97- eprintln ! ( "error: unmapped error: {kind}" ) ;
98+ error ! ( "Unmapped IO error: {:?}" , kind . to_string ( ) ) ;
9899 ErrorCode :: UnmappedError
99100 } ,
100101 }
@@ -103,21 +104,21 @@ impl From<std::io::Error> for ErrorCode {
103104
104105impl From < FromUtf8Error > for ErrorCode {
105106 fn from ( cause : FromUtf8Error ) -> Self {
106- eprintln ! ( "error: UTF-8 conversion failed: {cause :#?}" ) ;
107+ error ! ( "Conversion from UTF-8 failed: {:#?}" , cause ) ;
107108 ErrorCode :: ConversionFailed
108109 }
109110}
110111
111112impl From < TryFromSliceError > for ErrorCode {
112113 fn from ( cause : TryFromSliceError ) -> Self {
113- eprintln ! ( "error: try_into from slice failed: {cause :#?}" ) ;
114+ error ! ( "Conversion from slice failed: {:#?}" , cause ) ;
114115 ErrorCode :: ConversionFailed
115116 }
116117}
117118
118119impl From < Vec < u8 > > for ErrorCode {
119120 fn from ( cause : Vec < u8 > ) -> Self {
120- eprintln ! ( "error: try_into from u8 vector failed: {cause :#?}" ) ;
121+ error ! ( "Conversion from vector of u8 failed: {:#?}" , cause ) ;
121122 ErrorCode :: ConversionFailed
122123 }
123124}
0 commit comments