Skip to content

Commit

Permalink
feat: split errors to classes by types (#115)
Browse files Browse the repository at this point in the history
Signed-off-by: Valentinas <31697821+valentk777@users.noreply.github.com>
  • Loading branch information
valentk777 authored Feb 13, 2023
1 parent bd730a5 commit 5f348f4
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 2 deletions.
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)
{
}
}
}

0 comments on commit 5f348f4

Please sign in to comment.