11using System ;
22using System . Collections . Generic ;
3+ using Temporalio . Api . Enums . V1 ;
34using Temporalio . Api . Failure . V1 ;
45
56namespace Temporalio . Exceptions
@@ -25,18 +26,21 @@ public class ApplicationFailureException : FailureException
2526 /// <param name="nonRetryable">If true, marks the exception as non-retryable.</param>
2627 /// <param name="details">Collection of details to serialize into the exception.</param>
2728 /// <param name="nextRetryDelay">Override the next retry delay with this value.</param>
29+ /// <param name="category">Error category.</param>
2830 public ApplicationFailureException (
2931 string message ,
3032 string ? errorType = null ,
3133 bool nonRetryable = false ,
3234 IReadOnlyCollection < object ? > ? details = null ,
33- TimeSpan ? nextRetryDelay = null )
35+ TimeSpan ? nextRetryDelay = null ,
36+ ApplicationErrorCategory category = ApplicationErrorCategory . Unspecified )
3437 : base ( message )
3538 {
3639 ErrorType = errorType ;
3740 NonRetryable = nonRetryable ;
3841 Details = new OutboundFailureDetails ( details ?? Array . Empty < object ? > ( ) ) ;
3942 NextRetryDelay = nextRetryDelay ;
43+ Category = category ;
4044 }
4145
4246 /// <summary>
@@ -50,19 +54,22 @@ public ApplicationFailureException(
5054 /// <param name="nonRetryable">If true, marks the exception as non-retryable.</param>
5155 /// <param name="details">Collection of details to serialize into the exception.</param>
5256 /// <param name="nextRetryDelay">Override the next retry delay with this value.</param>
57+ /// <param name="category">Error category.</param>
5358 public ApplicationFailureException (
5459 string message ,
5560 Exception ? inner ,
5661 string ? errorType = null ,
5762 bool nonRetryable = false ,
5863 IReadOnlyCollection < object ? > ? details = null ,
59- TimeSpan ? nextRetryDelay = null )
64+ TimeSpan ? nextRetryDelay = null ,
65+ ApplicationErrorCategory category = ApplicationErrorCategory . Unspecified )
6066 : base ( message , inner )
6167 {
6268 ErrorType = errorType ;
6369 NonRetryable = nonRetryable ;
6470 Details = new OutboundFailureDetails ( details ) ;
6571 NextRetryDelay = nextRetryDelay ;
72+ Category = category ;
6673 }
6774
6875 /// <summary>
@@ -84,6 +91,7 @@ internal protected ApplicationFailureException(
8491 NonRetryable = info . NonRetryable ;
8592 Details = new InboundFailureDetails ( converter , info . Details ? . Payloads_ ) ;
8693 NextRetryDelay = info . NextRetryDelay ? . ToTimeSpan ( ) ;
94+ Category = info . Category ;
8795 }
8896
8997 /// <summary>
@@ -109,5 +117,10 @@ internal protected ApplicationFailureException(
109117 /// Gets the next retry delay override if any was set.
110118 /// </summary>
111119 public TimeSpan ? NextRetryDelay { get ; protected init ; }
120+
121+ /// <summary>
122+ /// Gets the error category.
123+ /// </summary>
124+ public ApplicationErrorCategory Category { get ; protected init ; }
112125 }
113126}
0 commit comments