@@ -97,28 +97,39 @@ public OperationResult AppendErrors(OperationResult otherOperationResult)
9797 /// This method will append an error with a specific `user-friendly` message to this operation result instance.
9898 /// </summary>
9999 /// <param name="message">A label consuming component defining the 'user-friendly' message.</param>
100- /// <param name="errorCode ">The unique code of the error.</param>
100+ /// <param name="code ">The unique code of the error.</param>
101101 /// <param name="logLevel">The logging severity.</param>
102+ /// <param name="details">A <see cref="string"/> with error details.</param>
102103 /// <returns>The current instance of the <see cref="OperationResult"/>.</returns>
103- public OperationResult AppendError ( string message , int errorCode = 0 , LogLevel ? logLevel = null )
104+ public OperationResult AppendError ( string message , int ? code = null , LogLevel ? logLevel = null , string ? details = null )
104105 {
105- if ( message is null ) throw new ArgumentNullException ( nameof ( message ) ) ;
106106 if ( string . IsNullOrWhiteSpace ( message ) ) throw new ArgumentNullException ( nameof ( message ) ) ;
107107
108- var error = new OperationError ( message , errorCode ) ;
108+ var error = new OperationError ( message , code ) { Details = details } ;
109109 this . AppendError ( error , logLevel ) ;
110110
111111 return this ;
112112 }
113113
114114 /// <summary>
115- /// Appends an error message to the operation result instance .
115+ /// Appends an <see cref="OperationError"/> to the internal errors collection .
116116 /// </summary>
117- /// <param name="message">The message that should be appended.</param>
118- /// <param name="errorCode">The unique code of the error.</param>
119- /// <param name="logLevel">The logging severity.</param>
117+ /// <param name="error">An instance of <see cref="OperationError"/> to add to the internal errors collection.</param>
118+ /// <param name="logLevel">The logging level.</param>
120119 /// <returns>The current instance of the <see cref="OperationResult"/>.</returns>
121- public OperationResult AppendErrorMessage ( string message , int errorCode = 0 , LogLevel ? logLevel = null ) => this . AppendError ( message , errorCode , logLevel ) ;
120+ public OperationResult AppendError ( OperationError error , LogLevel ? logLevel = LogLevel . Error )
121+ {
122+ this . AppendErrorInternal ( error ) ;
123+
124+ if ( this . _logger is not null )
125+ {
126+ #pragma warning disable CA2254 // Template should be a static expression
127+ this . _logger . Log ( GetLogLevel ( logLevel ) , error . Message ) ;
128+ #pragma warning restore CA2254 // Template should be a static expression
129+ }
130+
131+ return this ;
132+ }
122133
123134 /// <summary>
124135 /// 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.
@@ -149,26 +160,6 @@ public OperationResult AppendException(Exception exception, int errorCode = 0, L
149160 // TODO: this method needs completing.
150161 private static LogLevel GetLogLevel ( LogLevel ? optionalLevel ) => optionalLevel ?? LogLevel . Error ;
151162
152- /// <summary>
153- /// Appends an <see cref="OperationError"/> to the internal errors collection.
154- /// </summary>
155- /// <param name="error">An instance of <see cref="OperationError"/> to add to the internal errors collection.</param>
156- /// <param name="logLevel">The logging level.</param>
157- /// <returns>The current instance of the <see cref="OperationResult"/>.</returns>
158- public OperationResult AppendError ( OperationError error , LogLevel ? logLevel = LogLevel . Error )
159- {
160- this . AppendErrorInternal ( error ) ;
161-
162- if ( this . _logger is not null )
163- {
164- #pragma warning disable CA2254 // Template should be a static expression
165- this . _logger . Log ( GetLogLevel ( logLevel ) , error . Message ) ;
166- #pragma warning restore CA2254 // Template should be a static expression
167- }
168-
169- return this ;
170- }
171-
172163 /// <summary>
173164 /// Appends an <see cref="OperationError"/> to the internal errors collection.
174165 /// </summary>
@@ -229,12 +220,13 @@ public OperationResult(TResult resultObject) : base()
229220 /// This method will append an error with a specific `user-friendly` message to this operation result instance.
230221 /// </summary>
231222 /// <param name="message">A label consuming component defining the 'user-friendly' message.</param>
232- /// <param name="errorCode ">The unique code of the error.</param>
223+ /// <param name="code ">The unique code of the error.</param>
233224 /// <param name="logLevel">The logging severity.</param>
225+ /// <param name="details">A <see cref="string"/> with error details.</param>
234226 /// <returns>The current instance of the <see cref="OperationResult{TResult}"/>.</returns>
235- public new OperationResult < TResult > AppendError ( string message , int errorCode = 0 , LogLevel ? logLevel = null )
227+ public new OperationResult < TResult > AppendError ( string message , int ? code = null , LogLevel ? logLevel = null , string ? details = null )
236228 {
237- base . AppendError ( message , errorCode , logLevel ) ;
229+ base . AppendError ( message , code , logLevel , details ) ;
238230
239231 return this ;
240232 }
0 commit comments