@@ -49,16 +49,15 @@ pub enum Error {
4949 Convert ( ConvertError ) ,
5050}
5151
52- impl std :: fmt :: Display for Error {
53- fn fmt ( & self , f : & mut std :: fmt :: Formatter < ' _ > ) -> std :: fmt :: Result {
52+ impl Error {
53+ fn formatted_message ( & self ) -> String {
5454 match self {
55- Error :: Parsing ( msg) => write ! ( f, "ParseError: {msg}" ) ,
56- Error :: Protocol ( msg) => write ! ( f, "ProtocolError: {msg}" ) ,
57- Error :: Transport ( msg) => write ! ( f, "TransportError: {msg}" ) ,
58- Error :: IO ( msg) => write ! ( f, "IOError: {msg}" ) ,
59-
60- Error :: BadArgument ( msg) => write ! ( f, "BadArgument: {msg}" ) ,
61- Error :: InvalidResponse ( msg) => write ! ( f, "ResponseError: {msg}" ) ,
55+ Error :: Parsing ( msg) => format ! ( "ParseError: {msg}" ) ,
56+ Error :: Protocol ( msg) => format ! ( "ProtocolError: {msg}" ) ,
57+ Error :: Transport ( msg) => format ! ( "TransportError: {msg}" ) ,
58+ Error :: IO ( msg) => format ! ( "IOError: {msg}" ) ,
59+ Error :: BadArgument ( msg) => format ! ( "BadArgument: {msg}" ) ,
60+ Error :: InvalidResponse ( msg) => format ! ( "ResponseError: {msg}" ) ,
6261 Error :: Arrow ( e) => {
6362 let msg = match e {
6463 arrow_schema:: ArrowError :: IoError ( msg, _) => {
@@ -72,18 +71,28 @@ impl std::fmt::Display for Error {
7271 }
7372 other => format ! ( "{other}" ) ,
7473 } ;
75- write ! ( f , "ArrowError: {msg}" )
74+ format ! ( "ArrowError: {msg}" )
7675 }
77- Error :: Convert ( e) => write ! (
78- f,
76+ Error :: Convert ( e) => format ! (
7977 "ConvertError: cannot convert {} to {}: {:?}" ,
8078 e. data, e. target, e. message
8179 ) ,
82- Error :: Api ( e) => write ! ( f , "APIError: {e}" ) ,
80+ Error :: Api ( e) => format ! ( "APIError: {e}" ) ,
8381 }
8482 }
8583}
8684
85+ impl std:: fmt:: Display for Error {
86+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
87+ write ! (
88+ f,
89+ "{} [v{}]" ,
90+ self . formatted_message( ) ,
91+ env!( "CARGO_PKG_VERSION" )
92+ )
93+ }
94+ }
95+
8796impl std:: error:: Error for Error { }
8897
8998pub type Result < T , E = Error > = core:: result:: Result < T , E > ;
0 commit comments