Skip to content

Commit ecf04bb

Browse files
committed
fix warnings
1 parent 5d3c9cc commit ecf04bb

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

ManagedCode.Communication/Error.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public Error(string message, TErrorCode? errorCode = default)
1010
ErrorCode = errorCode;
1111
}
1212

13-
public Error(Exception exception, TErrorCode? errorCode = default)
13+
public Error(Exception? exception, TErrorCode? errorCode = default)
1414
{
1515
Exception = exception;
1616
ErrorCode = errorCode;
17-
Message = exception.Message ?? string.Empty;
17+
Message = exception?.Message ?? string.Empty;
1818
}
1919

2020
public Error(Exception exception, string message, TErrorCode? errorCode = default)
@@ -28,7 +28,7 @@ public Error(Exception exception, string message, TErrorCode? errorCode = defaul
2828
public Exception? Exception { get; set; }
2929
public TErrorCode? ErrorCode { get; set; }
3030

31-
public static Error<TErrorCode> FromException(Exception exception, TErrorCode? errorCode = default)
31+
public static Error<TErrorCode> FromException(Exception? exception, TErrorCode? errorCode = default)
3232
{
3333
return new Error<TErrorCode>(exception, errorCode);
3434
}

ManagedCode.Communication/Extensions/LoggerExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace ManagedCode.Communication.Extensions;
55

66
internal static class LoggerExtensions
77
{
8-
internal static void LogException(this ILogger logger, Exception exception)
8+
internal static void LogException(this ILogger logger, Exception? exception)
99
{
10-
logger.LogError(exception, exception.Message);
10+
logger.LogError(exception, exception?.Message);
1111
}
1212
}

ManagedCode.Communication/ManagedCode.Communication.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net7.0;netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<LangVersion>10</LangVersion>
77
<IsPackable>true</IsPackable>

ManagedCode.Communication/Result/Result.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static implicit operator Result(List<Error<ErrorCode>> errors)
2727
return new Result(errors);
2828
}
2929

30-
public static implicit operator Result(Exception exception)
30+
public static implicit operator Result(Exception? exception)
3131
{
3232
return new Result(Error<ErrorCode>.FromException(exception));
3333
}
@@ -52,7 +52,7 @@ public static Result Fail(List<Error<ErrorCode>> errors)
5252
return new Result(errors);
5353
}
5454

55-
public static Result Fail(Exception exception)
55+
public static Result Fail(Exception? exception)
5656
{
5757
return new Result(Error<ErrorCode>.FromException(exception));
5858
}
@@ -91,7 +91,7 @@ public static implicit operator Result<T>(List<Error<ErrorCode>> errors)
9191
return new Result<T>(errors);
9292
}
9393

94-
public static implicit operator Result<T>(Exception exception)
94+
public static implicit operator Result<T>(Exception? exception)
9595
{
9696
return new Result<T>(Error<ErrorCode>.FromException(exception));
9797
}
@@ -116,7 +116,7 @@ public static Result<T> Fail(List<Error<ErrorCode>> errors)
116116
return new Result<T>(errors);
117117
}
118118

119-
public static Result<T> Fail(Exception exception)
119+
public static Result<T> Fail(Exception? exception)
120120
{
121121
return new Result<T>(Error<ErrorCode>.FromException(exception));
122122
}

ManagedCode.Communication/ResultErrorHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public async Task<Result> ExecuteAsync(Func<Task<Result>> func,
3131

3232
return result;
3333
}
34-
catch (Exception e)
34+
catch (Exception? e)
3535
{
3636
_logger?.LogException(e);
3737

@@ -55,7 +55,7 @@ public async Task<Result<TValue>> ExecuteAsync<TValue>(Func<Task<Result<TValue>>
5555

5656
return result;
5757
}
58-
catch (Exception e)
58+
catch (Exception? e)
5959
{
6060
_logger?.LogException(e);
6161

@@ -80,7 +80,7 @@ public async Task<TResult> ExecuteAsync<TResult, TErrorCode>(Func<Task<TResult>>
8080

8181
return result;
8282
}
83-
catch (Exception e)
83+
catch (Exception? e)
8484
{
8585
_logger?.LogException(e);
8686

0 commit comments

Comments
 (0)