public DmarcConfigReadModelEntity(int domainId, int errorCount, ErrorType?maxErrorSeverity, string readModel) { DomainId = domainId; ErrorCount = errorCount; MaxErrorSeverity = maxErrorSeverity; ReadModel = readModel; }
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(); }
/// <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); }
/// <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; }
public SpfConfig(List <SpfRecord> records, List <Error> errors, int totalErrorCount, ErrorType?maxErrorSeverity, DateTime lastChecked) { Records = records; Errors = errors; TotalErrorCount = totalErrorCount; MaxErrorSeverity = maxErrorSeverity; LastChecked = lastChecked; }
public static FrontendBehavior CreateError(ErrorType errorType) { return(new() { ActionType = ActionType.Finish, Type = StepType.Error, Error = errorType }); }
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)); }
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; }
public static VideoResultError CreateInstance(string errorMessage, HttpContext httpContext, ErrorType?errorType) { return(new VideoResultError { ErrorMessage = errorMessage, TraceIdentifier = httpContext.TraceIdentifier, ErrorType = errorType }); }
/// <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); }
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)); }
protected Result(bool isSuccess, ErrorType?error) { if (isSuccess && error != null) { throw new InvalidOperationException(); } if (!isSuccess && error == null) { throw new InvalidOperationException(); } IsSuccess = isSuccess; Error = error; }
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); } }
protected ResultWithEnum(bool isSuccess, ErrorType?errorType) { if (isSuccess && errorType != null) { throw new InvalidOperationException(); } if (!isSuccess && errorType == null) { throw new InvalidOperationException(); } IsSuccess = isSuccess; ErrorType = errorType; }
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; } }
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; }
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)); } }
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); }
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); }
/// <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); }
protected Result(bool isSuccess, ErrorType?errorType) { IsSuccess = isSuccess; ErrorType = errorType; }
private OperationResult(bool isSuccess, string?message = null, ErrorType?errorType = null) { IsSuccess = isSuccess; ErrorType = errorType; Message = message; }
public static ResultWithEnum <T> Fail <T>(ErrorType?errorType) { return(new ResultWithEnum <T>(default(T), false, errorType)); }
public static ResultWithEnum Fail(ErrorType?errorType) { return(new ResultWithEnum(false, errorType)); }
private void ResetCreatePlaceObjectForm() { _newPlaceObjectDepth = null; _newPlaceCharacter = null; _whyCannotPlaceCharacter = null; }
public ExcelData(ErrorType errorType) { this._errorOut = errorType; }
public ExcelData(DataTable dataTable) { this._dataTable = dataTable; _errorOut = null; }
public ExcelData() { _errorOut = null; }
public ServiceResponse(bool success, ErrorType?errorType = null) { Success = success; ErrorType = errorType; }
protected BaseResponse(bool isSuccess, string errorMessage = null, ErrorType?errorType = null) { IsSuccess = isSuccess; ErrorMessage = errorMessage; Error = errorType; }
internal static string ToSerializedValue(this ErrorType?value) { return(value == null ? null : ((ErrorType)value).ToSerializedValue()); }
/// <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; }