コード例 #1
0
 public DmarcConfigReadModelEntity(int domainId, int errorCount, ErrorType?maxErrorSeverity, string readModel)
 {
     DomainId         = domainId;
     ErrorCount       = errorCount;
     MaxErrorSeverity = maxErrorSeverity;
     ReadModel        = readModel;
 }
コード例 #2
0
        async public virtual Task AuthenticateAsync(string email, string password)
        {
            // Already authenticated?
            if (Authenticated())
            {
                return;
            }

            try
            {
                var authData = await BackendUrl
                               .AppendPathSegment("users/auth")
                               .PostJsonAsync(new { email = email, password = password })
                               .ReceiveJson <IDictionary <string, string> >();

                // Make sure we got a token back
                if (!authData.ContainsKey("access_token"))
                {
                    CurError = ErrorType.AuthFailed;
                    return;
                }

                // Copy the auth token
                AuthToken = (string)authData["access_token"];
            }
            catch (FlurlHttpException ex)
            {
                ProcessHttpException(ex);
            }

            // Query our user with the shiny new auth token.
            await RefreshMe();
        }
コード例 #3
0
        /// <summary>
        /// Parses a Response from a raw JSON string
        /// </summary>
        public static Response ParseFrom(long token, string buf)
        {
            //we check here because it's possibly very expensive to ship this buf around in the call stack
            if (Log.IsTraceEnabled)
            {
                Log.Trace($"JSON Recv: Token: {token}, JSON: {buf}");
            }

            var       jsonResp      = ParseJson(buf);
            var       responseType  = jsonResp[TypeKey].ToObject <ResponseType>();
            var       responseNotes = jsonResp[NotesKey]?.ToObject <List <ResponseNote> >() ?? new List <ResponseNote>();
            ErrorType?et            = jsonResp[ErrorKey]?.ToObject <ErrorType>();

            var profile   = Profile.FromJsonArray((JArray)jsonResp[ProfileKey]);
            var backtrace = Backtrace.FromJsonArray((JArray)jsonResp[BacktraceKey]);

            var res = new Response(token, responseType)
            {
                ErrorType = et,
                Profile   = profile,
                Backtrace = backtrace,
                Data      = (JArray)jsonResp[DataKey] ?? new JArray(),
                Notes     = responseNotes
            };

            return(res);
        }
コード例 #4
0
 /// <summary>
 /// Constructor for ImportError
 /// </summary>
 /// <param name="errorType">
 ///<summary>
 /// TBD
 ///</summary>
 /// </param>
 /// <param name="lineNumber">
 ///<summary>
 /// TBD
 ///</summary>
 /// </param>
 /// <param name="bean">
 ///<summary>
 /// TBD
 ///</summary>
 /// </param>
 /// <param name="message">
 ///<summary>
 /// TBD
 ///</summary>
 /// </param>
 /// <param name="exceptionClass">
 ///<summary>
 /// TBD
 ///</summary>
 /// </param>
 public ImportError(ErrorType?errorType, long?lineNumber, string bean, string message, string exceptionClass)
 {
     this.ErrorType      = errorType;
     this.LineNumber     = lineNumber;
     this.Bean           = bean;
     this.Message        = message;
     this.ExceptionClass = exceptionClass;
 }
コード例 #5
0
 public SpfConfig(List <SpfRecord> records, List <Error> errors, int totalErrorCount, ErrorType?maxErrorSeverity, DateTime lastChecked)
 {
     Records          = records;
     Errors           = errors;
     TotalErrorCount  = totalErrorCount;
     MaxErrorSeverity = maxErrorSeverity;
     LastChecked      = lastChecked;
 }
コード例 #6
0
 public static FrontendBehavior CreateError(ErrorType errorType)
 {
     return(new()
     {
         ActionType = ActionType.Finish,
         Type = StepType.Error,
         Error = errorType
     });
 }
コード例 #7
0
        public IActionResult Error([FromQuery] ErrorType?errorType, [FromQuery] string?dependency)
        {
            if (errorType.HasValue)
            {
                HttpContext.SetSliError(errorType.Value, dependency);
            }

            return(StatusCode(500));
        }
        public void Test(DmarcRecord dmarcRecord, bool isErrorExpected, ErrorType?expectedError = null)
        {
            Error error;
            bool  isErrored = _rule.IsErrored(dmarcRecord, out error);

            Assert.That(isErrored, Is.EqualTo(isErrorExpected));

            Assert.That(error?.ErrorType, Is.EqualTo(expectedError));
        }
コード例 #9
0
 public DmarcConfig(List <DmarcRecord> records, List <Error> errors, int totalErrorCount, ErrorType?maxErrorSeverity, DateTime lastChecked, string inheritedFromOrgName)
 {
     Records          = records;
     Errors           = errors;
     TotalErrorCount  = totalErrorCount;
     MaxErrorSeverity = maxErrorSeverity;
     LastChecked      = lastChecked;
     InheritedFrom    = inheritedFromOrgName;
 }
コード例 #10
0
 public static VideoResultError CreateInstance(string errorMessage, HttpContext httpContext,
                                               ErrorType?errorType)
 {
     return(new VideoResultError
     {
         ErrorMessage = errorMessage,
         TraceIdentifier = httpContext.TraceIdentifier,
         ErrorType = errorType
     });
 }
コード例 #11
0
        /// <summary>
        /// Runs the <paramref name="func"/> checking against the expected outcomes.
        /// </summary>
        /// <param name="func">The function to execute.</param>
        /// <returns>The resulting <see cref="IValidationContextBase"/> where applicable; otherwise, <c>null</c>.</returns>
        public IValidationContextBase?Run(Func <IValidationContextBase> func)
        {
            PrepareExecutionContext(_username, _args);
            ExecutionContext.Current.OperationType = _operationType;

            if (IsExpectingError && !_expectedErrorType.HasValue)
            {
                _expectedErrorType = ErrorType.ValidationError;
            }

            try
            {
                var vc = Check.NotNull(func, nameof(func))();
                if (vc == null)
                {
                    Assert.Fail("The validation function returned a null IValidationContext result.");
                }

                if (vc !.HasErrors)
                {
                    LogStatus(ErrorType.ValidationError, new LText("Beef.ValidationException"), vc.Messages);
                }
                else
                {
                    LogStatus(null, null, null);
                }

                if (_expectedErrorType.HasValue)
                {
                    if (!vc !.HasErrors && _expectedErrorType != ErrorType.ValidationError)
                    {
                        Assert.Fail($"Expected ErrorType was '{_expectedErrorType}'; actual was '{ErrorType.ValidationError}'.");
                    }

                    if (_expectedErrorMessage != null)
                    {
                        var message = new LText("Beef.ValidationException");
                        if (_expectedErrorMessage != message)
                        {
                            Assert.Fail($"Expected ErrorMessage was '{_expectedErrorMessage}'; actual was '{message}'.");
                        }
                    }
                }

                if (_expectedMessages != null)
                {
                    ExpectValidationException.CompareExpectedVsActual(_expectedMessages, vc !.Messages);
                }

                return(vc);
            }
コード例 #12
0
ファイル: MapperExtension.cs プロジェクト: progvp/mail-check
        public static DmarcConfig ToDmarcConfig(this DomainDmarcConfig domainDmarcConfig)
        {
            List <DmarcRecord> dmarcRecords = domainDmarcConfig.Records.Select(ToDmarcRecord).ToList();

            List <Error> errors = domainDmarcConfig.Errors.Select(_ => _.ToError("Global"))
                                  .Concat(domainDmarcConfig.Records.SelectMany((v, i) => v.AllErrors.Select(_ => _.ToError($"Record {i + 1}"))))
                                  .ToList();

            ErrorType?maxErrorSeverity = errors.Any()
                ? errors.Min(_ => _.ErrorType)
                : (ErrorType?)null;

            return(new DmarcConfig(dmarcRecords, errors, domainDmarcConfig.AllErrorCount, maxErrorSeverity, domainDmarcConfig.LastChecked));
        }
コード例 #13
0
        protected Result(bool isSuccess, ErrorType?error)
        {
            if (isSuccess && error != null)
            {
                throw new InvalidOperationException();
            }
            if (!isSuccess && error == null)
            {
                throw new InvalidOperationException();
            }

            IsSuccess = isSuccess;
            Error     = error;
        }
コード例 #14
0
ファイル: ErrorUtils.cs プロジェクト: Anapher/PhotoFolder
        public static void AssertError(IUseCaseErrors errors, ErrorType?errorType = null, ErrorCode?code = null)
        {
            Assert.True(errors.HasError);

            if (errorType != null)
            {
                Assert.Equal(errorType.ToString(), errors.Error.Type);
            }

            if (code != null)
            {
                Assert.Equal((int)code, errors.Error.Code);
            }
        }
コード例 #15
0
        protected ResultWithEnum(bool isSuccess, ErrorType?errorType)
        {
            if (isSuccess && errorType != null)
            {
                throw new InvalidOperationException();
            }
            if (!isSuccess && errorType == null)
            {
                throw new InvalidOperationException();
            }

            IsSuccess = isSuccess;
            ErrorType = errorType;
        }
コード例 #16
0
 public void ProcessHttpException(FlurlHttpException ex)
 {
     if (ex.Call.Response != null)
     {
         // What was the error?
         dynamic res = ex.GetResponseJson();
         string  err = (string)res.err;
         CurError = ErrorTypeAPIParser.ParseStringErr(err);
     }
     else
     {
         // I don't know if a missing response always means a connection failed but what the hell
         CurError = ErrorType.ConnectionFailed;
     }
 }
コード例 #17
0
ファイル: Result.cs プロジェクト: davidikin45/AngularApp
        protected Result(bool isSuccess, ErrorType?errorType, IEnumerable <ValidationResult> objectValidationErrors, byte[] newRowVersion)
        {
            if (isSuccess && errorType != null)
            {
                throw new InvalidOperationException();
            }
            if (!isSuccess && errorType == null)
            {
                throw new InvalidOperationException();
            }

            IsSuccess = isSuccess;
            ErrorType = errorType;
            ObjectValidationErrors = objectValidationErrors;
            NewRowVersion          = newRowVersion;
        }
コード例 #18
0
        public void Test(SpfRecord spfRecord, string expectedError, ErrorType?expectedErrorType)
        {
            ShouldHaveHardFailAllEnabled shouldHaveHardFailAllEnabled = new ShouldHaveHardFailAllEnabled(new QualifierExplainer());

            bool hasError = shouldHaveHardFailAllEnabled.IsErrored(spfRecord, out Error error);

            if (expectedError == null)
            {
                Assert.That(error, Is.Null);
                Assert.That(hasError, Is.False);
            }
            else
            {
                Assert.That(hasError, Is.True);
                Assert.That(error.ErrorType, Is.EqualTo(expectedErrorType.Value));
                Assert.That(error.Message, Is.EqualTo(expectedError));
            }
        }
コード例 #19
0
		public void ReplaceWithResult(Value value, ResultSource source, params Node[] nodes)
		{
			ErrorType? errRep = null;
			Span span = Span.Empty;

			foreach (var node in nodes)
			{
				if (node == null) continue;

				errRep = errRep.Combine(node.ErrorReported);

				if (!node.Span.IsEmpty)
				{
					if (span.IsEmpty) span = node.Span;
					else span = span.Envelope(node.Span);
				}
			}

			ReplaceNodes(new ResultNode(Statement, span, value, source, errRep), nodes);
		}
コード例 #20
0
ファイル: ErrorType.cs プロジェクト: cmrazek/DkTools
 public static ErrorType?Combine(this ErrorType?a, ErrorType?b)
 {
     if (!a.HasValue && !b.HasValue)
     {
         return(null);
     }
     if (a.HasValue && !b.HasValue)
     {
         return(a.Value);
     }
     if (!a.HasValue && b.HasValue)
     {
         return(b.Value);
     }
     if (a.Value == ErrorType.Error || b.Value == ErrorType.Error)
     {
         return(ErrorType.Error);
     }
     return(a.Value);
 }
コード例 #21
0
        /// <summary>
        /// Parses a Response from a raw JSON string
        /// </summary>
        public static Response ParseFrom(long token, string buf)
        {
            Log.Trace($"JSON Recv: Token: {token}, JSON: {buf}");
            var       jsonResp      = JObject.Parse(buf);
            var       responseType  = jsonResp[TypeKey].ToObject <ResponseType>();
            var       responseNotes = jsonResp[NotesKey]?.ToObject <List <ResponseNote> >() ?? new List <ResponseNote>();
            ErrorType?et            = jsonResp[ErrorKey]?.ToObject <ErrorType>();

            var profile   = Profile.FromJsonArray((JArray)jsonResp[ProfileKey]);
            var backtrace = Backtrace.FromJsonArray((JArray)jsonResp[BacktraceKey]);

            var res = new Response(token, responseType)
            {
                ErrorType = et,
                Profile   = profile,
                Backtrace = backtrace,
                Data      = (JArray)jsonResp[DataKey] ?? new JArray(),
                Notes     = responseNotes
            };

            return(res);
        }
コード例 #22
0
ファイル: Result.cs プロジェクト: figofan/fluffy
 protected Result(bool isSuccess, ErrorType?errorType)
 {
     IsSuccess = isSuccess;
     ErrorType = errorType;
 }
コード例 #23
0
 private OperationResult(bool isSuccess, string?message = null, ErrorType?errorType = null)
 {
     IsSuccess = isSuccess;
     ErrorType = errorType;
     Message   = message;
 }
コード例 #24
0
 public static ResultWithEnum <T> Fail <T>(ErrorType?errorType)
 {
     return(new ResultWithEnum <T>(default(T), false, errorType));
 }
コード例 #25
0
 public static ResultWithEnum Fail(ErrorType?errorType)
 {
     return(new ResultWithEnum(false, errorType));
 }
コード例 #26
0
ファイル: FrameItemList.cs プロジェクト: wrightjjw/OpenSAGE
 private void ResetCreatePlaceObjectForm()
 {
     _newPlaceObjectDepth     = null;
     _newPlaceCharacter       = null;
     _whyCannotPlaceCharacter = null;
 }
コード例 #27
0
ファイル: ExcelData.cs プロジェクト: tah182/Comet
 public ExcelData(ErrorType errorType)
 {
     this._errorOut = errorType;
 }
コード例 #28
0
ファイル: ExcelData.cs プロジェクト: tah182/Comet
 public ExcelData(DataTable dataTable)
 {
     this._dataTable = dataTable;
     _errorOut = null;
 }
コード例 #29
0
ファイル: ExcelData.cs プロジェクト: tah182/Comet
 public ExcelData()
 {
     _errorOut = null;
 }
コード例 #30
0
 public ServiceResponse(bool success, ErrorType?errorType = null)
 {
     Success   = success;
     ErrorType = errorType;
 }
コード例 #31
0
 protected BaseResponse(bool isSuccess, string errorMessage = null, ErrorType?errorType = null)
 {
     IsSuccess    = isSuccess;
     ErrorMessage = errorMessage;
     Error        = errorType;
 }
コード例 #32
0
 internal static string ToSerializedValue(this ErrorType?value)
 {
     return(value == null ? null : ((ErrorType)value).ToSerializedValue());
 }
コード例 #33
0
ファイル: AgentTester.cs プロジェクト: keithlemon/Beef
 /// <summary>
 /// Expect a response with the specified <see cref="ErrorType"/>.
 /// </summary>
 /// <param name="errorType">The expected <see cref="ErrorType"/>.</param>
 /// <param name="errorMessage">The expected error message text; where not specified the error message text will not be checked.</param>
 protected void SetExpectErrorType(ErrorType errorType, string errorMessage = null)
 {
     _expectedErrorType    = errorType;
     _expectedErrorMessage = errorMessage;
 }