namespace Blahblah.Library.Network; public class NetworkResult { public T? Result { get; } public Exception? Exception { get; } public NetworkResult(T? obj, Exception? exception = null) { Result = obj; Exception = exception; } public void ThrowIfException(bool throwIfDefault = false) { if (Exception != null) { throw Exception; } if (throwIfDefault && Equals(Result, default)) { throw new Exception($"Network result is {{{default}}}"); } } public static implicit operator NetworkResult(T? obj) { return new(obj); } public static implicit operator NetworkResult(Exception ex) { return new(default, ex); } }