internal static string ToIdentifier(EvaluationErrorKind value) { switch (value) { case EvaluationErrorKind.ClientNotReady: return("CLIENT_NOT_READY"); case EvaluationErrorKind.FlagNotFound: return("FLAG_NOT_FOUND"); case EvaluationErrorKind.UserNotSpecified: return("USER_NOT_SPECIFIED"); case EvaluationErrorKind.MalformedFlag: return("MALFORMED_FLAG"); case EvaluationErrorKind.WrongType: return("WRONG_TYPE"); case EvaluationErrorKind.Exception: return("EXCEPTION"); default: throw new ArgumentException(); } }
internal EvaluationReason(EvaluationReasonKind kind, int ruleIndex, string ruleId, string prereqKey, EvaluationErrorKind errorKind) { _kind = kind; _ruleIndex = ruleIndex; _ruleId = ruleId; _prerequisiteKey = prereqKey; _errorKind = errorKind; }
internal EvaluationEvent NewUnknownFlagEvaluationEvent( string flagKey, User user, LdValue defaultValue, EvaluationErrorKind errorKind ) { return(new EvaluationEvent { Timestamp = UnixMillisecondTime.Now, User = user, FlagKey = flagKey, Value = defaultValue, Default = defaultValue, Reason = EvaluationReason.ErrorReason(errorKind) }); }
/// <summary> /// Returns an EvaluationReason of the kind <see cref="EvaluationReasonKind.ERROR"/>. /// </summary> /// <param name="errorKind"></param> /// <returns></returns> public static EvaluationReason ErrorReason(EvaluationErrorKind errorKind) { switch (errorKind) { case EvaluationErrorKind.CLIENT_NOT_READY: return(ErrorClientNotReady); case EvaluationErrorKind.FLAG_NOT_FOUND: return(ErrorFlagNotFound); case EvaluationErrorKind.USER_NOT_SPECIFIED: return(ErrorUserNotSpecified); case EvaluationErrorKind.MALFORMED_FLAG: return(ErrorMalformedFlag); case EvaluationErrorKind.WRONG_TYPE: return(ErrorWrongType); case EvaluationErrorKind.EXCEPTION: return(ErrorException); } return(new Error(errorKind)); }
internal EvaluationEvent NewDefaultValueEvaluationEvent( FeatureFlag flag, User user, LdValue defaultValue, EvaluationErrorKind errorKind ) { return(new EvaluationEvent { Timestamp = UnixMillisecondTime.Now, User = user, FlagKey = flag.Key, FlagVersion = flag.Version, Value = defaultValue, Default = defaultValue, Reason = EvaluationReason.ErrorReason(errorKind), TrackEvents = flag.TrackEvents, DebugEventsUntilDate = flag.DebugEventsUntilDate }); }
internal EvaluationDetail <JToken> ErrorResult(EvaluationErrorKind kind) { return(new EvaluationDetail <JToken>(null, null, new EvaluationReason.Error(kind))); }
/// <summary> /// Constructs a new Error instance. /// </summary> /// <param name="errorKind">the type of error</param> public Error(EvaluationErrorKind errorKind) : base(EvaluationReasonKind.ERROR, -1, null, null, errorKind) { }
private static EvaluationDetail <LdValue> ErrorResult(EvaluationErrorKind kind) => new EvaluationDetail <LdValue>(LdValue.Null, null, EvaluationReason.ErrorReason(kind));
/// <summary> /// Creates a feature request event for an evaluation that returned the default value /// when the flag did not exist or the feature store was unavailable. /// </summary> /// <param name="key">the flag key that was requested</param> /// <param name="user">the user passed to the Variation method</param> /// <param name="defaultVal">the default value passed to the Variation method</param> /// <param name="errorKind">the type of error</param> /// <returns>an event</returns> internal FeatureRequestEvent NewUnknownFeatureRequestEvent(string key, User user, LdValue defaultVal, EvaluationErrorKind errorKind) { return(new FeatureRequestEvent(GetTimestamp(), key, user, null, defaultVal, defaultVal, null, null, false, null, false, IncludeReasons ? EvaluationReason.ErrorReason(errorKind) : null)); }
/// <summary> /// Creates a feature request event for an evaluation that returned the default value /// (i.e. an error), even though the flag existed. /// </summary> /// <param name="flag">abstraction of the basic flag properties we need</param> /// <param name="user">the user passed to the Variation method</param> /// <param name="defaultVal">the default value passed to the Variation method</param> /// <param name="errorKind">the type of error</param> /// <returns>an event</returns> internal FeatureRequestEvent NewDefaultFeatureRequestEvent(IFlagEventProperties flag, User user, LdValue defaultVal, EvaluationErrorKind errorKind) { return(new FeatureRequestEvent(GetTimestamp(), flag.Key, user, null, defaultVal, defaultVal, flag.EventVersion, null, flag.TrackEvents, flag.DebugEventsUntilDate, false, IncludeReasons ? EvaluationReason.ErrorReason(errorKind) : null)); }
/// <summary> /// Returns an EvaluationReason of the kind <see cref="EvaluationReasonKind.Error"/>. /// </summary> /// <param name="errorKind"></param> /// <returns>a reason descriptor</returns> public static EvaluationReason ErrorReason(EvaluationErrorKind errorKind) => new EvaluationReason(EvaluationReasonKind.Error, null, null, null, errorKind, false, null);
public static void WriteJsonValue(EvaluationErrorKind instance, IValueWriter writer) => writer.String(ToIdentifier((EvaluationErrorKind)instance));
internal EvaluationDetail <LdValue> ErrorResult(EvaluationErrorKind kind) { return(new EvaluationDetail <LdValue>(LdValue.Null, null, EvaluationReason.ErrorReason(kind))); }