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

feat: split errors to classes by types #115

Merged
merged 2 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/OpenFeature/Error/FeatureProviderException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
namespace OpenFeature.Error
{
/// <summary>
/// Used to represent an abnormal error when evaluating a flag. This exception should be thrown
/// when evaluating a flag inside a IFeatureFlag provider
/// Used to represent an abnormal error when evaluating a flag.
/// This exception should be thrown when evaluating a flag inside a IFeatureFlag provider
/// </summary>
public class FeatureProviderException : Exception
{
Expand Down
21 changes: 21 additions & 0 deletions src/OpenFeature/Error/FlagNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using OpenFeature.Constant;

namespace OpenFeature.Error
{
/// <summary>
/// Provider was unable to find the flag error when evaluating a flag.
/// </summary>
public class FlagNotFoundException : FeatureProviderException
{
/// <summary>
/// Initialize a new instance of the <see cref="FlagNotFoundException"/> class
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="innerException">Optional inner exception</param>
public FlagNotFoundException(string message = null, Exception innerException = null)
: base(ErrorType.FlagNotFound, message, innerException)
{
}
}
}
21 changes: 21 additions & 0 deletions src/OpenFeature/Error/GeneralException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using OpenFeature.Constant;

namespace OpenFeature.Error
{
/// <summary>
/// Abnormal execution of the provider when evaluating a flag.
/// </summary>
public class GeneralException : FeatureProviderException
{
/// <summary>
/// Initialize a new instance of the <see cref="GeneralException"/> class
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="innerException">Optional inner exception</param>
public GeneralException(string message = null, Exception innerException = null)
: base(ErrorType.General, message, innerException)
{
}
}
}
21 changes: 21 additions & 0 deletions src/OpenFeature/Error/InvalidContextException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using OpenFeature.Constant;

namespace OpenFeature.Error
{
/// <summary>
/// Context does not satisfy provider requirements when evaluating a flag.
/// </summary>
public class InvalidContextException : FeatureProviderException
{
/// <summary>
/// Initialize a new instance of the <see cref="InvalidContextException"/> class
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="innerException">Optional inner exception</param>
public InvalidContextException(string message = null, Exception innerException = null)
: base(ErrorType.InvalidContext, message, innerException)
{
}
}
}
21 changes: 21 additions & 0 deletions src/OpenFeature/Error/ParseErrorException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using OpenFeature.Constant;

namespace OpenFeature.Error
{
/// <summary>
/// Provider failed to parse the flag response when evaluating a flag.
/// </summary>
public class ParseErrorException : FeatureProviderException
{
/// <summary>
/// Initialize a new instance of the <see cref="ParseErrorException"/> class
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="innerException">Optional inner exception</param>
public ParseErrorException(string message = null, Exception innerException = null)
: base(ErrorType.ParseError, message, innerException)
{
}
}
}
21 changes: 21 additions & 0 deletions src/OpenFeature/Error/ProviderNotReadyException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using OpenFeature.Constant;

namespace OpenFeature.Error
{
/// <summary>
/// Provider has yet been initialized when evaluating a flag.
/// </summary>
public class ProviderNotReadyException : FeatureProviderException
{
/// <summary>
/// Initialize a new instance of the <see cref="ProviderNotReadyException"/> class
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="innerException">Optional inner exception</param>
public ProviderNotReadyException(string message = null, Exception innerException = null)
: base(ErrorType.ProviderNotReady, message, innerException)
{
}
}
}
21 changes: 21 additions & 0 deletions src/OpenFeature/Error/TargetingKeyMissingException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using OpenFeature.Constant;

namespace OpenFeature.Error
{
/// <summary>
/// Context does not contain a targeting key and the provider requires one when evaluating a flag.
/// </summary>
public class TargetingKeyMissingException : FeatureProviderException
{
/// <summary>
/// Initialize a new instance of the <see cref="TargetingKeyMissingException"/> class
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="innerException">Optional inner exception</param>
public TargetingKeyMissingException(string message = null, Exception innerException = null)
: base(ErrorType.TargetingKeyMissing, message, innerException)
{
}
}
}
21 changes: 21 additions & 0 deletions src/OpenFeature/Error/TypeMismatchException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using OpenFeature.Constant;

namespace OpenFeature.Error
{
/// <summary>
/// Request type does not match the expected type when evaluating a flag.
/// </summary>
public class TypeMismatchException : FeatureProviderException
{
/// <summary>
/// Initialize a new instance of the <see cref="TypeMismatchException"/> class
/// </summary>
/// <param name="message">Exception message</param>
/// <param name="innerException">Optional inner exception</param>
public TypeMismatchException(string message = null, Exception innerException = null)
: base(ErrorType.TypeMismatch, message, innerException)
{
}
}
}