-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ToErrorOr, Updated Docs & change else to return ErrorOr
- Loading branch information
1 parent
515ac3c
commit a757b15
Showing
8 changed files
with
889 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace ErrorOr; | ||
|
||
public static partial class ErrorOrExtensions | ||
{ | ||
/// <summary> | ||
/// Creates an <see cref="ErrorOr{TValue}"/> instance with the given <paramref name="value"/>. | ||
/// </summary> | ||
public static ErrorOr<TValue> ToErrorOr<TValue>(this TValue value) | ||
{ | ||
return value; | ||
} | ||
|
||
/// <summary> | ||
/// Creates an <see cref="ErrorOr{TValue}"/> instance with the given <paramref name="error"/>. | ||
/// </summary> | ||
public static ErrorOr<TValue> ToErrorOr<TValue>(this Error error) | ||
{ | ||
return error; | ||
} | ||
|
||
/// <summary> | ||
/// Creates an <see cref="ErrorOr{TValue}"/> instance with the given <paramref name="error"/>. | ||
/// </summary> | ||
public static ErrorOr<TValue> ToErrorOr<TValue>(this List<Error> error) | ||
{ | ||
return error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,40 @@ | ||
namespace ErrorOr; | ||
|
||
/// <summary> | ||
/// Provides factory methods for creating instances of <see cref="ErrorOr{TValue}"/>. | ||
/// </summary> | ||
public static class ErrorOrFactory | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of <see cref="ErrorOr{TValue}"/> with a value. | ||
/// </summary> | ||
/// <typeparam name="TValue">The type of the value.</typeparam> | ||
/// <param name="value">The value to wrap.</param> | ||
/// <returns>An instance of <see cref="ErrorOr{TValue}"/> containing the provided value.</returns> | ||
public static ErrorOr<TValue> From<TValue>(TValue value) | ||
{ | ||
return value; | ||
} | ||
} | ||
namespace ErrorOr; | ||
|
||
/// <summary> | ||
/// Provides factory methods for creating instances of <see cref="ErrorOr{TValue}"/>. | ||
/// </summary> | ||
public static class ErrorOrFactory | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of <see cref="ErrorOr{TValue}"/> with a value. | ||
/// </summary> | ||
/// <typeparam name="TValue">The type of the value.</typeparam> | ||
/// <param name="value">The value to wrap.</param> | ||
/// <returns>An instance of <see cref="ErrorOr{TValue}"/> containing the provided value.</returns> | ||
public static ErrorOr<TValue> From<TValue>(TValue value) | ||
{ | ||
return value; | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance of <see cref="ErrorOr{TValue}"/> with a value. | ||
/// </summary> | ||
/// <typeparam name="TValue">The type of the value.</typeparam> | ||
/// <param name="value">The value to wrap.</param> | ||
/// <returns>An instance of <see cref="ErrorOr{TValue}"/> containing the provided value.</returns> | ||
public static ErrorOr<TValue> From<TValue>(Error value) | ||
{ | ||
return value; | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new instance of <see cref="ErrorOr{TValue}"/> with a value. | ||
/// </summary> | ||
/// <typeparam name="TValue">The type of the value.</typeparam> | ||
/// <param name="value">The value to wrap.</param> | ||
/// <returns>An instance of <see cref="ErrorOr{TValue}"/> containing the provided value.</returns> | ||
public static ErrorOr<TValue> From<TValue>(List<Error> value) | ||
{ | ||
return value; | ||
} | ||
} |
Oops, something went wrong.