@@ -91,9 +91,10 @@ pub enum BuilderErrorKind {
9191}
9292
9393impl BuilderErrorKind {
94- const INVALID_URI_TEMPLATE : & ' static str = "Invalid URI provided" ;
95- const INVALID_TELEMETRY_CONFIG_TEMPLATE : & ' static str = "Invalid telemetry configuration" ;
96- const INVALID_CONFIGURATION_TEMPLATE : & ' static str = "Invalid configuration" ;
94+ const INVALID_URI_TEMPLATE : & ' static str = "Invalid URI provided: {details}" ;
95+ const INVALID_TELEMETRY_CONFIG_TEMPLATE : & ' static str =
96+ "Invalid telemetry configuration: {details}" ;
97+ const INVALID_CONFIGURATION_TEMPLATE : & ' static str = "Invalid configuration: {details}" ;
9798}
9899
99100impl Display for BuilderErrorKind {
@@ -143,7 +144,8 @@ pub enum InternalErrorKind {
143144}
144145
145146impl InternalErrorKind {
146- const INVALID_WORKER_STATE_TEMPLATE : & ' static str = "Background worker in invalid state" ;
147+ const INVALID_WORKER_STATE_TEMPLATE : & ' static str =
148+ "Background worker in invalid state: {details}" ;
147149}
148150
149151impl Display for InternalErrorKind {
@@ -274,7 +276,8 @@ pub struct RequestError {
274276}
275277
276278impl RequestError {
277- const REQUEST_ERROR_TEMPLATE : & ' static str = "Agent responded with error status" ;
279+ const REQUEST_ERROR_TEMPLATE : & ' static str =
280+ "Agent responded with error status {status_code}: {response}" ;
278281}
279282
280283impl Display for RequestError {
@@ -322,7 +325,8 @@ pub enum ShutdownError {
322325}
323326
324327impl ShutdownError {
325- const TIMED_OUT_TEMPLATE : & ' static str = "Shutdown operation timed out" ;
328+ const TIMED_OUT_TEMPLATE : & ' static str =
329+ "Shutdown operation timed out after {timeout_seconds} seconds" ;
326330}
327331
328332impl Display for ShutdownError {
@@ -352,11 +356,11 @@ impl ErrorTemplate for ShutdownError {
352356impl ErrorTemplate for DecodeError {
353357 fn template ( & self ) -> & ' static str {
354358 match self {
355- DecodeError :: InvalidConversion ( _) => "Failed to convert decoded value" ,
356- DecodeError :: InvalidType ( _) => "Invalid type in trace payload" ,
357- DecodeError :: InvalidFormat ( _) => "Invalid msgpack format" ,
359+ DecodeError :: InvalidConversion ( _) => "Failed to convert decoded value: {details} " ,
360+ DecodeError :: InvalidType ( _) => "Invalid type in trace payload: {details} " ,
361+ DecodeError :: InvalidFormat ( _) => "Invalid msgpack format: {details} " ,
358362 DecodeError :: IOError => "Failed to read from buffer" ,
359- DecodeError :: Utf8Error ( _) => "Failed to decode UTF-8 string" ,
363+ DecodeError :: Utf8Error ( _) => "Failed to decode UTF-8 string: {details} " ,
360364 }
361365 }
362366
@@ -575,8 +579,8 @@ impl ErrorTemplate for TraceExporterError {
575579 TraceExporterError :: Shutdown ( e) => e. template ( ) ,
576580 TraceExporterError :: Deserialization ( e) => e. template ( ) ,
577581 TraceExporterError :: Io ( io_error) => Self :: io_error_template ( io_error) ,
578- TraceExporterError :: Telemetry ( _) => "Telemetry operation failed" ,
579- TraceExporterError :: Serialization ( _) => "Failed to serialize data" ,
582+ TraceExporterError :: Telemetry ( _) => "Telemetry operation failed: {details} " ,
583+ TraceExporterError :: Serialization ( _) => "Failed to serialize data: {details} " ,
580584 }
581585 }
582586
@@ -657,7 +661,7 @@ mod tests {
657661 #[ test]
658662 fn test_builder_error_template ( ) {
659663 let error = BuilderErrorKind :: InvalidUri ( "invalid://url" . to_string ( ) ) ;
660- assert_eq ! ( error. template( ) , "Invalid URI provided" ) ;
664+ assert_eq ! ( error. template( ) , "Invalid URI provided: {details} " ) ;
661665 let context = error. context ( ) ;
662666 assert_eq ! ( context. fields( ) . len( ) , 1 ) ;
663667 assert_eq ! (
@@ -666,7 +670,10 @@ mod tests {
666670 ) ;
667671
668672 let error = BuilderErrorKind :: InvalidTelemetryConfig ( "missing field" . to_string ( ) ) ;
669- assert_eq ! ( error. template( ) , "Invalid telemetry configuration" ) ;
673+ assert_eq ! (
674+ error. template( ) ,
675+ "Invalid telemetry configuration: {details}"
676+ ) ;
670677 let context = error. context ( ) ;
671678 assert_eq ! ( context. fields( ) . len( ) , 1 ) ;
672679 assert_eq ! (
@@ -675,7 +682,7 @@ mod tests {
675682 ) ;
676683
677684 let error = BuilderErrorKind :: InvalidConfiguration ( "bad setting" . to_string ( ) ) ;
678- assert_eq ! ( error. template( ) , "Invalid configuration" ) ;
685+ assert_eq ! ( error. template( ) , "Invalid configuration: {details} " ) ;
679686 let context = error. context ( ) ;
680687 assert_eq ! ( context. fields( ) . len( ) , 1 ) ;
681688 assert_eq ! (
@@ -687,7 +694,10 @@ mod tests {
687694 #[ test]
688695 fn test_internal_error_template ( ) {
689696 let error = InternalErrorKind :: InvalidWorkerState ( "worker crashed" . to_string ( ) ) ;
690- assert_eq ! ( error. template( ) , "Background worker in invalid state" ) ;
697+ assert_eq ! (
698+ error. template( ) ,
699+ "Background worker in invalid state: {details}"
700+ ) ;
691701 let context = error. context ( ) ;
692702 assert_eq ! ( context. fields( ) . len( ) , 1 ) ;
693703 assert_eq ! (
@@ -761,7 +771,10 @@ mod tests {
761771 #[ test]
762772 fn test_request_error_template ( ) {
763773 let error = RequestError :: new ( StatusCode :: NOT_FOUND , "Resource not found" ) ;
764- assert_eq ! ( error. template( ) , "Agent responded with error status" ) ;
774+ assert_eq ! (
775+ error. template( ) ,
776+ "Agent responded with error status {status_code}: {response}"
777+ ) ;
765778 let context = error. context ( ) ;
766779 assert_eq ! ( context. fields( ) . len( ) , 2 ) ;
767780 assert_eq ! (
@@ -774,7 +787,10 @@ mod tests {
774787 ) ;
775788
776789 let error = RequestError :: new ( StatusCode :: INTERNAL_SERVER_ERROR , "Server error" ) ;
777- assert_eq ! ( error. template( ) , "Agent responded with error status" ) ;
790+ assert_eq ! (
791+ error. template( ) ,
792+ "Agent responded with error status {status_code}: {response}"
793+ ) ;
778794 let context = error. context ( ) ;
779795 assert_eq ! ( context. fields( ) . len( ) , 2 ) ;
780796 assert_eq ! (
@@ -792,7 +808,10 @@ mod tests {
792808 use std:: time:: Duration ;
793809
794810 let error = ShutdownError :: TimedOut ( Duration :: from_secs ( 5 ) ) ;
795- assert_eq ! ( error. template( ) , "Shutdown operation timed out" ) ;
811+ assert_eq ! (
812+ error. template( ) ,
813+ "Shutdown operation timed out after {timeout_seconds} seconds"
814+ ) ;
796815 let context = error. context ( ) ;
797816 assert_eq ! ( context. fields( ) . len( ) , 1 ) ;
798817 assert_eq ! (
@@ -801,7 +820,10 @@ mod tests {
801820 ) ;
802821
803822 let error = ShutdownError :: TimedOut ( Duration :: from_millis ( 2500 ) ) ;
804- assert_eq ! ( error. template( ) , "Shutdown operation timed out" ) ;
823+ assert_eq ! (
824+ error. template( ) ,
825+ "Shutdown operation timed out after {timeout_seconds} seconds"
826+ ) ;
805827 let context = error. context ( ) ;
806828 assert_eq ! ( context. fields( ) . len( ) , 1 ) ;
807829 assert_eq ! (
0 commit comments