Skip to content

Commit 9825c33

Browse files
author
tgancheva
committed
Move public method.
1 parent cda0215 commit 9825c33

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

src/OneBitSoftware.Utilities.OperationResult/OperationResult.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,26 @@ public OperationResult AppendError(string message, int errorCode = 0, LogLevel?
110110
return this;
111111
}
112112

113+
/// <summary>
114+
/// Appends an <see cref="OperationError"/> to the internal errors collection.
115+
/// </summary>
116+
/// <param name="error">An instance of <see cref="OperationError"/> to add to the internal errors collection.</param>
117+
/// <param name="logLevel">The logging level.</param>
118+
/// <returns>The current instance of the <see cref="OperationResult"/>.</returns>
119+
public OperationResult AppendError(OperationError error, LogLevel? logLevel = LogLevel.Error)
120+
{
121+
this.AppendErrorInternal(error);
122+
123+
if (this._logger is not null)
124+
{
125+
#pragma warning disable CA2254 // Template should be a static expression
126+
this._logger.Log(GetLogLevel(logLevel), error.Message);
127+
#pragma warning restore CA2254 // Template should be a static expression
128+
}
129+
130+
return this;
131+
}
132+
113133
/// <summary>
114134
/// 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.
115135
/// </summary>
@@ -139,26 +159,6 @@ public OperationResult AppendException(Exception exception, int errorCode = 0, L
139159
// TODO: this method needs completing.
140160
private static LogLevel GetLogLevel(LogLevel? optionalLevel) => optionalLevel ?? LogLevel.Error;
141161

142-
/// <summary>
143-
/// Appends an <see cref="OperationError"/> to the internal errors collection.
144-
/// </summary>
145-
/// <param name="error">An instance of <see cref="OperationError"/> to add to the internal errors collection.</param>
146-
/// <param name="logLevel">The logging level.</param>
147-
/// <returns>The current instance of the <see cref="OperationResult"/>.</returns>
148-
public OperationResult AppendError(OperationError error, LogLevel? logLevel = LogLevel.Error)
149-
{
150-
this.AppendErrorInternal(error);
151-
152-
if (this._logger is not null)
153-
{
154-
#pragma warning disable CA2254 // Template should be a static expression
155-
this._logger.Log(GetLogLevel(logLevel), error.Message);
156-
#pragma warning restore CA2254 // Template should be a static expression
157-
}
158-
159-
return this;
160-
}
161-
162162
/// <summary>
163163
/// Appends an <see cref="OperationError"/> to the internal errors collection.
164164
/// </summary>

0 commit comments

Comments
 (0)