Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions for invalid use - review and extensions #106

Prev Previous commit
Next Next commit
docs: add XML docs for exceptions
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
  • Loading branch information
feO2x committed May 9, 2024
commit 6fffb3ee13c453497639654a30b3c216c52300ae
4 changes: 4 additions & 0 deletions src/ErrorOr/ErrorOr.ImplicitConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static implicit operator ErrorOr<TValue>(Error error)
/// <summary>
/// Creates an <see cref="ErrorOr{TValue}"/> from a list of errors.
/// </summary>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="errors"/> is null.</exception>
/// <exception cref="InvalidOperationException">Thrown when <paramref name="errors" /> is an empty list.</exception>
public static implicit operator ErrorOr<TValue>(List<Error> errors)
{
if (errors is null)
Expand All @@ -39,6 +41,8 @@ public static implicit operator ErrorOr<TValue>(List<Error> errors)
/// <summary>
/// Creates an <see cref="ErrorOr{TValue}"/> from a list of errors.
/// </summary>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="errors"/> is null.</exception>
/// <exception cref="InvalidOperationException">Thrown when <paramref name="errors" /> is an empty array.</exception>
public static implicit operator ErrorOr<TValue>(Error[] errors)
{
if (errors is null)
Expand Down
8 changes: 5 additions & 3 deletions src/ErrorOr/ErrorOr.ToErrorOrExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ public static ErrorOr<TValue> ToErrorOr<TValue>(this Error error)
}

/// <summary>
/// Creates an <see cref="ErrorOr{TValue}"/> instance with the given <paramref name="error"/>.
/// Creates an <see cref="ErrorOr{TValue}"/> instance with the given <paramref name="errors"/>.
/// </summary>
public static ErrorOr<TValue> ToErrorOr<TValue>(this List<Error> error)
/// <exception cref="ArgumentNullException">Thrown when <paramref name="errors"/> is null.</exception>
/// <exception cref="InvalidOperationException">Thrown when <paramref name="errors" /> is an empty list.</exception>
public static ErrorOr<TValue> ToErrorOr<TValue>(this List<Error> errors)
{
return error;
return errors;
}
}