@@ -73,7 +73,17 @@ public static async Task<TOutput> Convert<TInput, TOutput>(this Task<TInput> tas
7373 /// <param name="task">The task to convert.</param>
7474 /// <typeparam name="T">The type of the task.</typeparam>
7575 /// <returns>The task that never throws an exception. Instead, the <see cref="Result{T}"/> contains an exception.</returns>
76+ [ Obsolete ( "Use CatchException() instead." ) ]
7677 public static AwaitableResult < T > SuspendException < T > ( this Task < T > task )
78+ => CatchException ( task ) ;
79+
80+ /// <summary>
81+ /// Returns a task that never throws an exception.
82+ /// </summary>
83+ /// <param name="task">The task to convert.</param>
84+ /// <typeparam name="T">The type of the task.</typeparam>
85+ /// <returns>The task that never throws an exception. Instead, the <see cref="Result{T}"/> contains an exception.</returns>
86+ public static AwaitableResult < T > CatchException < T > ( this Task < T > task )
7787 {
7888 ArgumentNullException . ThrowIfNull ( task ) ;
7989
@@ -86,7 +96,16 @@ public static AwaitableResult<T> SuspendException<T>(this Task<T> task)
8696 /// <param name="task">The task to convert.</param>
8797 /// <typeparam name="T">The type of the task.</typeparam>
8898 /// <returns>The task that never throws an exception. Instead, the <see cref="Result{T}"/> contains an exception.</returns>
89- public static AwaitableResult < T > SuspendException < T > ( this ValueTask < T > task ) => new ( task ) ;
99+ [ Obsolete ( "Use CatchException() instead." ) ]
100+ public static AwaitableResult < T > SuspendException < T > ( this ValueTask < T > task ) => CatchException ( task ) ;
101+
102+ /// <summary>
103+ /// Returns a task that never throws an exception.
104+ /// </summary>
105+ /// <param name="task">The task to convert.</param>
106+ /// <typeparam name="T">The type of the task.</typeparam>
107+ /// <returns>The task that never throws an exception. Instead, the <see cref="Result{T}"/> contains an exception.</returns>
108+ public static AwaitableResult < T > CatchException < T > ( this ValueTask < T > task ) => new ( task ) ;
90109
91110 /// <summary>
92111 /// Returns a task that never throws an exception.
@@ -96,7 +115,21 @@ public static AwaitableResult<T> SuspendException<T>(this Task<T> task)
96115 /// <typeparam name="T">The type of the task.</typeparam>
97116 /// <typeparam name="TError">The type of the error.</typeparam>
98117 /// <returns>The task that never throws an exception. Instead, the <see cref="Result{T}"/> contains an exception.</returns>
118+ [ Obsolete ( "Use CatchException() instead." ) ]
99119 public static AwaitableResult < T , TError > SuspendException < T , TError > ( this ValueTask < T > task ,
120+ Converter < Exception , TError > converter )
121+ where TError : struct , Enum
122+ => CatchException ( task , converter ) ;
123+
124+ /// <summary>
125+ /// Returns a task that never throws an exception.
126+ /// </summary>
127+ /// <param name="task">The task to convert.</param>
128+ /// <param name="converter">The exception converter.</param>
129+ /// <typeparam name="T">The type of the task.</typeparam>
130+ /// <typeparam name="TError">The type of the error.</typeparam>
131+ /// <returns>The task that never throws an exception. Instead, the <see cref="Result{T}"/> contains an exception.</returns>
132+ public static AwaitableResult < T , TError > CatchException < T , TError > ( this ValueTask < T > task ,
100133 Converter < Exception , TError > converter )
101134 where TError : struct , Enum
102135 => new ( task , converter ) ;
@@ -109,10 +142,28 @@ public static AwaitableResult<T, TError> SuspendException<T, TError>(this ValueT
109142 /// <typeparam name="T">The type of the task.</typeparam>
110143 /// <typeparam name="TError">The type of the error.</typeparam>
111144 /// <returns>The task that never throws an exception. Instead, the <see cref="Result{T}"/> contains an exception.</returns>
145+ [ Obsolete ( "Use CatchException() instead." ) ]
112146 public static AwaitableResult < T , TError > SuspendException < T , TError > ( this Task < T > task ,
113147 Converter < Exception , TError > converter )
114148 where TError : struct , Enum
115- => new ( task , converter ) ;
149+ => CatchException ( task , converter ) ;
150+
151+ /// <summary>
152+ /// Returns a task that never throws an exception.
153+ /// </summary>
154+ /// <param name="task">The task to convert.</param>
155+ /// <param name="converter">The exception converter.</param>
156+ /// <typeparam name="T">The type of the task.</typeparam>
157+ /// <typeparam name="TError">The type of the error.</typeparam>
158+ /// <returns>The task that never throws an exception. Instead, the <see cref="Result{T}"/> contains an exception.</returns>
159+ public static AwaitableResult < T , TError > CatchException < T , TError > ( this Task < T > task ,
160+ Converter < Exception , TError > converter )
161+ where TError : struct , Enum
162+ {
163+ ArgumentNullException . ThrowIfNull ( task ) ;
164+
165+ return new ( task , converter ) ;
166+ }
116167
117168 /// <summary>
118169 /// Suspends the exception that can be raised by the task.
0 commit comments