Skip to content

Commit d39e579

Browse files
Added support for generic return types
1 parent 0bb101c commit d39e579

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

src/OneBitSoftware.Utilities.OperationResult/OneBitSoftware.Utilities.OperationResult.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
3232
<PackageReadmeFile>README.md</PackageReadmeFile>
3333
<PackageTags>OneBitSoftware; OperationResult;</PackageTags>
34-
<Version>1.0.2</Version>
34+
<Version>1.0.3</Version>
3535
</PropertyGroup>
3636

3737
</Project>

src/OneBitSoftware.Utilities.OperationResult/OperationResult.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,33 @@ public OperationResult(ILogger loggerService, TResult resultObject)
250250
/// Gets or sets the related object of the operation.
251251
/// </summary>
252252
public TResult? RelatedObject { get; set; }
253+
254+
/// <summary>
255+
/// This method will append an error with a specific `user-friendly` message to this operation result instance.
256+
/// </summary>
257+
/// <param name="message">A label consuming component defining the 'user-friendly' message.</param>
258+
/// <param name="errorCode">The unique code of the error.</param>
259+
/// <param name="logLevel">The logging severity.</param>
260+
/// <returns>The current instance of the <see cref="OperationResult{TResult}"/>.</returns>
261+
public new OperationResult<TResult> AppendError(string message, int errorCode = 0, LogLevel? logLevel = null)
262+
{
263+
base.AppendError(message, errorCode, logLevel);
264+
265+
return this;
266+
}
267+
268+
/// <summary>
269+
/// Appends an exception to the error message collection and logs the full exception as an Error <see cref="LogEventLevel"/> level. A call to this method will set the Success property to false.
270+
/// </summary>
271+
/// <param name="exception">The exception to log.</param>
272+
/// <param name="errorCode">The error code.</param>
273+
/// <param name="logLevel">The <see cref="LogEventLevel"/> logging severity.</param>
274+
/// <returns>The current instance of the <see cref="OperationResult{TResult}"/>.</returns>
275+
public new OperationResult<TResult> AppendException(Exception exception, int errorCode = 0, LogLevel? logLevel = null)
276+
{
277+
base.AppendException(exception, errorCode, logLevel);
278+
279+
return this;
280+
}
253281
}
254282
}

0 commit comments

Comments
 (0)