-
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.
Improve exceptions details for GetUnsafe methods on monads (#372)
* Add NoneStateException for Maybe<T> * Use explicit exceptions for GetUnsafe methods on Result * Fix typos in Xml Docs * Comply to ISerializable implementation * Add missing Serializable attribute
- Loading branch information
Showing
8 changed files
with
81 additions
and
27 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
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,24 @@ | ||
using System; | ||
using Vonage.Common.Failures; | ||
|
||
namespace Vonage.Common.Monads.Exceptions; | ||
|
||
/// <summary> | ||
/// Represents errors that occurs when a Result is in a Failure state. | ||
/// </summary> | ||
[Serializable] | ||
public class FailureStateException : Exception | ||
{ | ||
/// <summary> | ||
/// Gets the failure value of the Result. | ||
/// </summary> | ||
public IResultFailure Failure { get; } | ||
|
||
/// <summary> | ||
/// Creates a FailureStateException. | ||
/// </summary> | ||
/// <param name="failure">The failure value of the Result.</param> | ||
public FailureStateException(IResultFailure failure) | ||
: base("State is Failure.") => | ||
this.Failure = failure; | ||
} |
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,18 @@ | ||
using System; | ||
|
||
namespace Vonage.Common.Monads.Exceptions; | ||
|
||
/// <summary> | ||
/// Represents errors that occurs when a Maybe is in a None state. | ||
/// </summary> | ||
[Serializable] | ||
public class NoneStateException : Exception | ||
{ | ||
/// <summary> | ||
/// Creates a NoneStateException. | ||
/// </summary> | ||
public NoneStateException() | ||
: base("State is None.") | ||
{ | ||
} | ||
} |
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,23 @@ | ||
using System; | ||
|
||
namespace Vonage.Common.Monads.Exceptions; | ||
|
||
/// <summary> | ||
/// Represents errors that occurs when a Result is in a Success state. | ||
/// </summary> | ||
[Serializable] | ||
public class SuccessStateException<T> : Exception | ||
{ | ||
/// <summary> | ||
/// Gets the success value of the Result. | ||
/// </summary> | ||
public T Success { get; } | ||
|
||
/// <summary> | ||
/// Creates a SuccessStateException. | ||
/// </summary> | ||
/// <param name="success">The success value of the Result.</param> | ||
public SuccessStateException(T success) | ||
: base("State is Success.") => | ||
this.Success = success; | ||
} |
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
This file was deleted.
Oops, something went wrong.