@@ -38,14 +38,29 @@ public class FailureDetails : IEquatable<FailureDetails>
3838 /// <param name="stackTrace">The exception stack trace.</param>
3939 /// <param name="innerFailure">The inner cause of the failure.</param>
4040 /// <param name="isNonRetriable">Whether the failure is non-retriable.</param>
41+ /// <param name="properties">Additional properties associated with the failure.</param>
4142 [ JsonConstructor ]
42- public FailureDetails ( string errorType , string errorMessage , string ? stackTrace , FailureDetails ? innerFailure , bool isNonRetriable )
43+ public FailureDetails ( string errorType , string errorMessage , string ? stackTrace , FailureDetails ? innerFailure , bool isNonRetriable , IDictionary < string , object > ? properties = null )
4344 {
4445 this . ErrorType = errorType ;
4546 this . ErrorMessage = errorMessage ;
4647 this . StackTrace = stackTrace ;
4748 this . InnerFailure = innerFailure ;
4849 this . IsNonRetriable = isNonRetriable ;
50+ this . Properties = properties ;
51+ }
52+
53+ /// <summary>
54+ /// Initializes a new instance of the <see cref="FailureDetails"/> class.
55+ /// </summary>
56+ /// <param name="errorType">The name of the error, which is expected to the the namespace-qualified name of the exception type.</param>
57+ /// <param name="errorMessage">The message associated with the error, which is expected to be the exception's <see cref="Exception.Message"/> property.</param>
58+ /// <param name="stackTrace">The exception stack trace.</param>
59+ /// <param name="innerFailure">The inner cause of the failure.</param>
60+ /// <param name="isNonRetriable">Whether the failure is non-retriable.</param>
61+ public FailureDetails ( string errorType , string errorMessage , string ? stackTrace , FailureDetails ? innerFailure , bool isNonRetriable )
62+ : this ( errorType , errorMessage , stackTrace , innerFailure , isNonRetriable , properties : null )
63+ {
4964 }
5065
5166 /// <summary>
@@ -54,7 +69,7 @@ public FailureDetails(string errorType, string errorMessage, string? stackTrace,
5469 /// <param name="e">The exception used to generate the failure details.</param>
5570 /// <param name="innerFailure">The inner cause of the failure.</param>
5671 public FailureDetails ( Exception e , FailureDetails innerFailure )
57- : this ( e , innerFailure , null )
72+ : this ( e , innerFailure , properties : null )
5873 {
5974 }
6075
@@ -63,31 +78,29 @@ public FailureDetails(Exception e, FailureDetails innerFailure)
6378 /// </summary>
6479 /// <param name="e">The exception used to generate the failure details.</param>
6580 public FailureDetails ( Exception e )
66- : this ( e , ( IExceptionPropertiesProvider ? ) null )
81+ : this ( e , properties : null )
6782 {
6883 }
6984
7085 /// <summary>
7186 /// Initializes a new instance of the <see cref="FailureDetails"/> class from an exception object.
7287 /// </summary>
7388 /// <param name="e">The exception used to generate the failure details.</param>
74- /// <param name="exceptionPropertiesProvider ">The provider to extract custom properties from the exception .</param>
75- public FailureDetails ( Exception e , IExceptionPropertiesProvider ? exceptionPropertiesProvider )
76- : this ( e . GetType ( ) . FullName , GetErrorMessage ( e ) , e . StackTrace , FromException ( e . InnerException , exceptionPropertiesProvider ) , false )
89+ /// <param name="properties ">The exception properties to include in failure details .</param>
90+ public FailureDetails ( Exception e , IDictionary < string , object > ? properties )
91+ : this ( e . GetType ( ) . FullName , GetErrorMessage ( e ) , e . StackTrace , FromException ( e . InnerException ) , false , properties )
7792 {
78- this . Properties = GetExceptionProperties ( e , exceptionPropertiesProvider ) ;
7993 }
8094
8195 /// <summary>
8296 /// Initializes a new instance of the <see cref="FailureDetails"/> class from an exception object.
8397 /// </summary>
8498 /// <param name="e">The exception used to generate the failure details.</param>
8599 /// <param name="innerFailure">The inner cause of the failure.</param>
86- /// <param name="exceptionPropertiesProvider ">The provider to extract custom properties from the exception .</param>
87- public FailureDetails ( Exception e , FailureDetails innerFailure , IExceptionPropertiesProvider ? exceptionPropertiesProvider )
88- : this ( e . GetType ( ) . FullName , GetErrorMessage ( e ) , e . StackTrace , innerFailure , false )
100+ /// <param name="properties ">The exception properties to include in failure details .</param>
101+ public FailureDetails ( Exception e , FailureDetails innerFailure , IDictionary < string , object > ? properties )
102+ : this ( e . GetType ( ) . FullName , GetErrorMessage ( e ) , e . StackTrace , innerFailure , false , properties )
89103 {
90- this . Properties = GetExceptionProperties ( e , exceptionPropertiesProvider ) ;
91104 }
92105
93106 /// <summary>
@@ -243,31 +256,12 @@ static string GetErrorMessage(Exception e)
243256
244257 static FailureDetails ? FromException ( Exception ? e )
245258 {
246- return FromException ( e , null ) ;
247- }
248-
249- static FailureDetails ? FromException ( Exception ? e , IExceptionPropertiesProvider ? provider )
250- {
251- return e == null ? null : new FailureDetails ( e , provider ) ;
259+ return FromException ( e , properties : null ) ;
252260 }
253261
254- static IDictionary < string , object > ? GetExceptionProperties ( Exception exception , IExceptionPropertiesProvider ? provider )
262+ static FailureDetails ? FromException ( Exception ? e , IDictionary < string , object > ? properties )
255263 {
256- // If this is a TaskFailedException that already has FailureDetails with properties,
257- // use those properties instead of asking the provider
258- if ( exception is OrchestrationException orchestrationException &&
259- orchestrationException . FailureDetails ? . Properties != null )
260- {
261- return orchestrationException . FailureDetails . Properties ;
262- }
263-
264- if ( provider == null )
265- {
266- return null ;
267- }
268-
269- // If there is a provider provided, then extract exception properties with the provider.
270- return provider . GetExceptionProperties ( exception ) ;
264+ return e == null ? null : new FailureDetails ( e , properties : properties ) ;
271265 }
272266
273267 }
0 commit comments