예제 #1
0
 private static Exception CreateParseException(
     ExpressionError expressionError,
     Lexeme lexeme,
     IError innerError = null)
 {
     throw new ExpressionParseException(Error.From(expressionError, lexeme, innerError));
 }
예제 #2
0
 public CommentController(IPost postRepository, IComment commentsRepository, ISettings settingsRepository, ICacheService cacheService, IError errorLogger)
     : base(settingsRepository)
 {
     _postRepository = postRepository;
     _cacheService = cacheService;
     _commentsRepository = commentsRepository;
     _errorLogger = errorLogger;
 }
예제 #3
0
파일: cerror.cs 프로젝트: ChuangYang/corefx
        static internal void Dispose()
        {
            //Reset the info.  
            s_rIError = null;
            s_rITestConsole = null;

            //Remove listeners
            s_rLTMConsole = null;
        }
        private static string BuildExceptionMessage(IError error)
        {
            if (error == null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            return $"HTTP {error.HttpStatus}, Stormpath {error.Code} ({error.MoreInfo}): {error.DeveloperMessage}";
        }
예제 #5
0
 public CommentProcessorPipeline(IComment commentRepository, ISettings settingsRepository, IAkismetService akismetService, IError error, CommentEntity commentEntity, RequestData requestData)
 {
     _commentRepository = commentRepository;
     _settingsRepository = settingsRepository;
     _akismetService = akismetService;
     _error = error;
     _commentEntity = commentEntity;
     _requestData = requestData;
 }
예제 #6
0
        public static IRoute AddError(this IRoute route, IError error)
        {
            if (!route.Contains(KnownParameters.Errors))
                route.AddParameter(KnownParameters.Errors, new List<IError>());

            var errors = route[KnownParameters.Errors] as List<IError>;
            errors.Add(error);

            return route;
        }
		public ProcessResult AddError(IError error)
		{
			if (_errors.Contains(error))
				return this;

			var foundError = error as ContentControlNotFoundError;
			if (foundError != null)
			{
				if (HandledItems.Contains(foundError.ContentItem))
					return this;
			}

			_errors.Add(error);
			return this;
		}
예제 #8
0
 internal DeezerException(IError aError)
 { 
     iError = aError;
     switch (aError.Code)
     {
         case 4:   { iMessage = QUOTA_EXCEPTION;   break; }
         case 200: { iMessage = OAUTH_EXCEPTION_P; break; }
         case 300: { iMessage = OAUTH_EXCEPTION_T; break; }
         case 500: { iMessage = PARAM_EXCEPTION;   break; }
         case 501: { iMessage = MISSING_EXCEPTION; break; }
         case 600: { iMessage = INVALID_EXCEPTION; break; }
         case 700: { iMessage = SERVICE_EXCEPTION; break; }
         case 800: { iMessage = DATA_EXCEPTION;    break; }
         default:  { iMessage = "An unknown exception has occured..."; break; }
     }
 }
예제 #9
0
        public void Run()
        {
            string input;

            while (!(input = Console.ReadLine()).Equals("END"))
            {
                string[] errorArg = input.Split('|');
                string   level    = errorArg[0];
                string   dateTime = errorArg[1];
                string   message  = errorArg[2];

                IError error = this.errorFactory
                               .CreateError(dateTime, level, message);

                this.logger.Log(error);
            }
        }
예제 #10
0
    public async Task AsyncSync_失敗の場合はActionが実行され値が返る()
    {
        var    error     = new Error();
        var    errResult = Result.Error(error).AsTask();
        var    executed  = false;
        IError param     = null;
        var    result    = await errResult.FlatMapError(e =>
        {
            executed = true;
            param    = e;
            return(Result.Ok());
        });

        executed.Should().BeTrue();
        param.Should().Be(error);
        result.Should().BeOk();
    }
        public void Append(IError error)
        {
            string format = Layout.Format;

            DateTime timeOfOccurrence = error.TimeOfOccurrence;
            Level    level            = error.Level;
            string   message          = error.Message;

            string formattedMessage = string.Format(format,
                                                    timeOfOccurrence.ToString(datetimeFormat,
                                                                              CultureInfo.InvariantCulture),
                                                    level.ToString(),
                                                    message);

            Console.WriteLine(formattedMessage);
            MessagesCount++;
        }
예제 #12
0
    public async Task AsyncSync_失敗の場合はアクションが実行されてその結果が返る()
    {
        var    actionResult   = "NG";
        var    actionExecuted = false;
        var    sourceError    = new Error();
        IError paramError     = null;
        var    result         = await Result.Error <string>(sourceError).AsTask().GetOr(e =>
        {
            paramError     = e;
            actionExecuted = true;
            return(actionResult);
        });

        actionExecuted.Should().BeTrue();
        paramError.Should().BeSameAs(sourceError);
        result.Should().Be(actionResult);
    }
예제 #13
0
        public void Append(IError error)
        {
            string format = this.Layout.Format;

            DateTime dateTime = error.DateTime;
            Level    level    = error.Level;
            string   message  = error.Message;

            string formattedMessage = String.Format(format,
                                                    dateTime.ToString(dateFormat,
                                                                      CultureInfo.InvariantCulture)
                                                    , level.ToString(),
                                                    message);

            Console.WriteLine(formattedMessage);
            this.messagesAppended++;
        }
예제 #14
0
            public static async Task InsertErrorAsync(IError error)
            {
                // Create a command object identifying the stored procedure
                using (var cmd = new SqlCommand("sp_InsertErrorLog"))
                {
                    //
                    // Set the command object so it knows to execute a stored procedure
                    cmd.CommandType = CommandType.StoredProcedure;
                    //
                    // Add parameters to command, which will be passed to the stored procedure
                    if (error.Snapshot != null)
                    {
                        cmd.Parameters.AddWithValue("@ScreenCapture", error.Snapshot.ToBytes());
                    }


                    cmd.Parameters.AddWithValue("@ServerDateTime", error.ServerDateTime);
                    cmd.Parameters.AddWithValue("@Host", error.Host);
                    cmd.Parameters.AddWithValue("@User", error.User);
                    cmd.Parameters.AddWithValue("@IsHandled", error.IsHandled);
                    cmd.Parameters.AddWithValue("@Type", error.ErrorType);
                    cmd.Parameters.AddWithValue("@AppName", error.AppName);
                    cmd.Parameters.AddWithValue("@CurrentCulture", error.CurrentCulture);
                    cmd.Parameters.AddWithValue("@CLRVersion", error.ClrVersion);
                    cmd.Parameters.AddWithValue("@Message", error.Message);
                    cmd.Parameters.AddWithValue("@Source", error.Source ?? "");
                    cmd.Parameters.AddWithValue("@StackTrace", error.StackTrace);
                    cmd.Parameters.AddWithValue("@ModuleName", error.ModuleName);
                    cmd.Parameters.AddWithValue("@MemberType", error.MemberType);
                    cmd.Parameters.AddWithValue("@Method", error.Method);
                    cmd.Parameters.AddWithValue("@Processes", error.Processes);
                    cmd.Parameters.AddWithValue("@ErrorDateTime", error.ErrorDateTime);
                    cmd.Parameters.AddWithValue("@OS", error.OS);
                    cmd.Parameters.AddWithValue("@IPv4Address", error.IPv4Address);
                    cmd.Parameters.AddWithValue("@MACAddress", error.MacAddress);
                    cmd.Parameters.AddWithValue("@HResult", error.HResult);
                    cmd.Parameters.AddWithValue("@Line", error.LineColumn.Line);
                    cmd.Parameters.AddWithValue("@Column", error.LineColumn.Column);
                    cmd.Parameters.AddWithValue("@Duplicate", error.Duplicate);
                    cmd.Parameters.AddWithValue("@Data", error.Data);
                    //
                    // execute the command

                    await ConnectionManager.GetDefaultConnection().ExecuteNonQueryAsync(cmd);
                }
            }
        private void ReportError(IExecutionTask task, IError error)
        {
            if (task is null)
            {
                throw new ArgumentNullException(nameof(task));
            }

            if (error is null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            AssertNotPooled();
            error = ErrorHandler.Handle(error);
            Result.AddError(error);
            DiagnosticEvents.TaskError(task, error);
        }
예제 #16
0
    public override void Append(IError error)
    {
        ErrorTreshholds errorTreshhold = error.ReportLevel;
        string          dateTime       = error.DateTime;
        string          message        = error.Message;

        if (errorTreshhold >= this.ReportLevelTreshhold)
        {
            StringBuilder result = new StringBuilder();

            result.AppendFormat(this.Layout.Format, dateTime, errorTreshhold.ToString(), message);

            Console.WriteLine(result);

            this.MessagesAppendedCount++;
        }
    }
        /// <summary>
        /// Inserts a user to the database. Returns true if successful
        /// </summary>
        public bool InsertUser(User user)
        {
            IError error = ErrorInit();

            try
            {
                repo.Insert(user);
                return(true);
            }
            catch (Exception ex)
            {
                error = Helpers.ErrorMessage(ErrorType.NoUniqueID,
                                             ex.Message);
                errorService.Write(error);
                return(false);
            }
        }
        IError IDataService.UpdateItemActive(IItemActive item)
        {
            IError error = ErrorInit();

            try
            {
                repo.Update((ItemActive)item);
                return(error);
            }
            catch (Exception ex)
            {
                error = Helpers.ErrorMessage(ErrorType.DatabaseError,
                                             ex.Message);
                errorService.Write(error);
                return(error);
            }
        }
        public void Append(IError error)
        {
            string format = this.Layout.Format;

            DateTime dateTime = error.DateTime;

            Level level = error.Level;

            string message = error.Message;

            string formatedmessage = string.Format(format, dateTime.ToString("M/dd/yyy H:mm:ss tt", CultureInfo.InvariantCulture),
                                                   message, level.ToString());

            Console.WriteLine(formatedmessage);

            this.MessagesAppended++;
        }
예제 #20
0
        private static void DeserializeErrors(
            IQueryResultBuilder result,
            IReadOnlyDictionary <string, object?> serializedResult)
        {
            if (serializedResult.TryGetValue(_errors, out object?o) &&
                o is IReadOnlyList <object> errors)
            {
                foreach (var obj in errors)
                {
                    IError error = ErrorBuilder
                                   .FromDictionary(DeserializeErrorObject(obj))
                                   .Build();

                    result.AddError(error);
                }
            }
        }
예제 #21
0
    public async Task SyncAsync_失敗の場合はActionが実行され結果が返る()
    {
        var    error     = new Error();
        var    errResult = Result.Error <string>(error);
        var    executed  = false;
        IError param     = null;
        var    result    = await errResult.FlatMapError(e =>
        {
            executed = true;
            param    = e;
            return(Result.Ok("success").AsTask());
        });

        executed.Should().BeTrue();
        param.Should().Be(error);
        result.Should().BeOk().And.Match(v => v == "success");
    }
예제 #22
0
        public static async Task ExecuteTasksAsync(
            IOperationContext operationContext)
        {
            if (operationContext.Execution.TaskBacklog.IsEmpty)
            {
                return;
            }

            var proposedTaskCount = operationContext.Operation.ProposedTaskCount;

            if (proposedTaskCount == 1)
            {
                await ExecuteResolversAsync(
                    operationContext.Execution,
                    HandleError,
                    operationContext.RequestAborted);
            }
            else
            {
                var tasks = new Task[proposedTaskCount];

                for (var i = 0; i < proposedTaskCount; i++)
                {
                    tasks[i] = ExecuteResolversAsync(
                        operationContext.Execution,
                        HandleError,
                        operationContext.RequestAborted);
                }

                await Task.WhenAll(tasks).ConfigureAwait(false);
            }

            void HandleError(Exception exception)
            {
                IError error =
                    operationContext.ErrorHandler
                    .CreateUnexpectedError(exception)
                    .SetCode(ErrorCodes.Execution.TaskProcessingError)
                    .Build();

                error = operationContext.ErrorHandler.Handle(error);

                // TODO : this error needs to be reported!
                operationContext.Result.AddError(error);
            }
        }
예제 #23
0
    public async Task AsyncSync_失敗の場合はアクションが実行されて結果が返る()
    {
        var    executed    = false;
        var    expected    = new Error();
        IError param       = null;
        var    resultError = new Error();
        var    result      = await Result.Error(expected).AsTask().MapError(e =>
        {
            executed = true;
            param    = e;
            return(resultError);
        });

        executed.Should().BeTrue();
        param.Should().Be(expected);
        result.Should().BeError().And.Match(e => Object.ReferenceEquals(e, resultError));
    }
예제 #24
0
        public async Task InvokeAsync(HttpContext context)
        {
            if (_isPathValid(context) && CanHandleRequest(context))
            {
                try
                {
                    await HandleRequestAsync(context)
                    .ConfigureAwait(false);
                }
                catch (ArgumentException)
                {
                    context.Response.StatusCode = _badRequest;
                }
                catch (NotSupportedException)
                {
                    context.Response.StatusCode = _badRequest;
                }
                catch (SyntaxException ex)
                {
                    IError error = ErrorBuilder.New()
                                   .SetMessage(ex.Message)
                                   .AddLocation(ex.Line, ex.Column)
                                   .SetCode(ErrorCodes.Execution.SyntaxError)
                                   .Build();
                    ErrorHandler.Handle(error);

                    var errorResult = QueryResultBuilder.CreateError(error);

                    SetResponseHeaders(context.Response, _serializer.ContentType);
                    await _serializer.SerializeAsync(errorResult, context.Response.Body)
                    .ConfigureAwait(false);
                }
                catch (QueryException ex)
                {
                    var errorResult = QueryResultBuilder.CreateError(
                        ErrorHandler.Handle(ex.Errors));
                    SetResponseHeaders(context.Response, _serializer.ContentType);
                    await _serializer.SerializeAsync(errorResult, context.Response.Body)
                    .ConfigureAwait(false);
                }
            }
            else if (Next != null)
            {
                await Next.Invoke(context).ConfigureAwait(false);
            }
        }
예제 #25
0
        private void CreateArgumentValue(
            FieldInfo fieldInfo,
            IInputField argument,
            IValueNode literal)
        {
            if (fieldInfo.Arguments == null)
            {
                fieldInfo.Arguments =
                    new Dictionary <NameString, ArgumentValue>();
            }

            Report report = ArgumentNonNullValidator.Validate(
                argument.Type,
                literal,
                Path.New(argument.Name));

            if (report.HasErrors)
            {
                IError error = ErrorBuilder.New()
                               .SetMessage(string.Format(
                                               CultureInfo.InvariantCulture,
                                               TypeResources.ArgumentValueBuilder_NonNull,
                                               argument.Name,
                                               TypeVisualizer.Visualize(report.Type)))
                               .AddLocation(fieldInfo.Selection)
                               .SetExtension(_argumentProperty, report.Path.ToCollection())
                               .SetPath(fieldInfo.Path.AppendOrCreate(
                                            fieldInfo.ResponseName))
                               .Build();

                fieldInfo.Arguments[argument.Name] =
                    new ArgumentValue(argument.Type, error);
            }
            else if (argument.Type.IsLeafType())
            {
                fieldInfo.Arguments[argument.Name] =
                    new ArgumentValue(
                        argument.Type,
                        ParseLiteral(argument.Type, literal));
            }
            else
            {
                fieldInfo.Arguments[argument.Name] =
                    new ArgumentValue(argument.Type, literal);
            }
        }
예제 #26
0
    public IError OnError(IError error)
    {
        if (error.Exception is ValidationException vx)
        {
            var childErrors =
                vx.Errors.Select(x => new FluentValidationProblemDetail(x))
                .Select(
                    x => new Error(x.ErrorMessage)
                    .WithCode(x.ErrorCode)
                    .SetExtension("severity", x.Severity.ToString())
                    .SetExtension("attemptedValue", x.AttemptedValue)
                    .SetExtension("field", x.PropertyName)
                    .SetExtension("propertyName", x.PropertyName)
                    );
            var result = new AggregateError(childErrors);
            return(result);
        }

        if (error.Exception is IProblemDetailsData ex)
        {
            var builder = ErrorBuilder.FromError(error);
            builder
            .SetException(error.Exception)
            .SetMessage(error.Exception.Message)
            .WithProblemDetails(ex);

            if (error.Exception is NotFoundException)
            {
                builder.SetCode("NOTFOUND");
            }

            if (error.Exception is NotAuthorizedException)
            {
                builder.SetCode("NOTAUTHORIZED");
            }

            if (error.Exception is RequestFailedException)
            {
                builder.SetCode("FAILED");
            }

            return(builder.Build());
        }

        return(error);
    }
예제 #27
0
        private void ExecuteDelete <T>(DataGridViewRow currentRow, ReportConfigManagerBase <T> mgr) where T : IReportItem
        {
            if (this.ComfirmDeleteItem(currentRow))
            {
                T item = (T)currentRow.DataBoundItem;

                IError error = mgr.RemoveItem(item.Name);
                if (error.HasError)
                {
                    MessageBox.Show("Can not remove the item. \n" + error.ErrorMessage);
                }
                else
                {
                    this.RefreshUI();
                }
            }
        }
예제 #28
0
        bool IDataService.InsertGroup(Groups groups)
        {
            IError error = ErrorInit();

            try
            {
                repo.Insert(groups);
                return(true);
            }
            catch (Exception ex)
            {
                error = Helpers.ErrorMessage(ErrorType.NoUniqueID,
                                             ex.Message);
                errorService.Write(error);
                return(false);
            }
        }
예제 #29
0
        IError IDataService.InsertConnection(IConnection connection)
        {
            IError error = ErrorInit();

            try
            {
                repo.Insert((Connection)connection);
                return(error);
            }
            catch (Exception ex)
            {
                error = Helpers.ErrorMessage(ErrorType.NoUniqueID,
                                             ex.Message);
                errorService.Write(error);
                return(error);
            }
        }
예제 #30
0
        IError IDataService.InsertPortActive(IPortActive port)
        {
            IError error = ErrorInit();

            try
            {
                repo.Insert((PortActive)port);
                return(error);
            }
            catch (Exception ex)
            {
                error = Helpers.ErrorMessage(ErrorType.NoUniqueID,
                                             ex.Message);
                errorService.Write(error);
                return(error);
            }
        }
예제 #31
0
        IError IDataService.InsertSymbol(ISymbol symbol)
        {
            IError error = ErrorInit();

            try
            {
                repo.Insert((Symbol)symbol);
                return(error);
            }
            catch (Exception ex)
            {
                error = Helpers.ErrorMessage(ErrorType.NoUniqueID,
                                             ex.Message);
                errorService.Write(error);
                return(error);
            }
        }
        public async Task <IActionResult> ExecuteFunctionsQueryAsync(HttpContext httpContext, ILogger logger, CancellationToken cancellationToken)
        {
            try
            {
                //Use the Middleware Proxy to Invoke the pre-configured pipeline for Http POST & GET processing...
                var httpMiddlewareProxy = this.AzureFunctionsMiddlewareProxy;
                await httpMiddlewareProxy.InvokeAsync(httpContext);
            }
            //NOTE: We Implement error handling that matches the Existing HttpPostMiddleware, to ensure that all code
            //  has top level error handling for Graph processing.
            catch (GraphQLRequestException ex)
            {
                //If Debugging is enabled then Log the Errors to AzureFunctions framework (e.g. Application Insights)
                logger.LogDebug(ex, $"{nameof(GraphQLRequestException)} occurred while processing the GraphQL request; {ex.Message}.");

                // A GraphQL request exception is thrown if the HTTP request body couldn't be parsed.
                // In this case we will return HTTP status code 400 and return a GraphQL error result.
                IErrorHandler errorHandler = await this.AzureFunctionsMiddlewareProxy.GetErrorHandlerAsync(cancellationToken);

                IQueryResult errorResult = QueryResultBuilder.CreateError(errorHandler.Handle(ex.Errors));

                await HandleGraphQLErrorResponseAsync(httpContext, HttpStatusCode.BadRequest, errorResult);
            }
            catch (Exception exc)
            {
                //Log all Unknown Exceptions as GraphQLExceptions to Azure Framework (e.g. Application Insights).
                logger.LogError(exc, "An unhandled exception occurred while processing the GraphQL request.");

                // An unknown and unexpected GraphQL request exception was encountered.
                // In this case we will return HTTP status code 500 and return a GraphQL error result.
                IErrorHandler errorHandler = await this.AzureFunctionsMiddlewareProxy.GetErrorHandlerAsync(cancellationToken);

                IError       error       = errorHandler.CreateUnexpectedError(exc).Build();
                IQueryResult errorResult = QueryResultBuilder.CreateError(error);

                HttpStatusCode statusCode = exc is HttpRequestException
                    ? HttpStatusCode.BadRequest
                    : HttpStatusCode.InternalServerError;

                await HandleGraphQLErrorResponseAsync(httpContext, statusCode, errorResult);
            }

            //Safely resolve the .Net Core request with Empty Result because the Response has already been handled!
            return(new EmptyResult());
        }
예제 #33
0
        public void Run(string task)
        {
            ReportItemDictionary <ReportTask> tasks = ReportConfig.ReportTaskManager.ItemCollection;

            ExportEngine engine = new ExportEngine(new QlikViewConnector());

            engine.Logger = this.Logger;

            ReportTask taskItem = tasks.Values.FirstOrDefault(x => x.Name.ToString() == task);

            if (taskItem != null)
            {
                Console.WriteLine("Running task first time: " + taskItem.Name + ".......");
                engine.Logger.Message("Running task first time: " + taskItem.Name + ".......");
                IError error = engine.RunTask(taskItem, ReportConfig.SmtpServerManager.SmtpServer);

                if (error.HasError == false)
                {
                    Console.WriteLine("Running task fisrt time" + taskItem.Name + " complete.......");
                    engine.Logger.Message("Running task fisrt time" + taskItem.Name + " complete.......");
                }
                else
                {
                    Console.WriteLine("Running task fisrt time " + taskItem.Name + " failed.......");
                    engine.Logger.Error("Running task fisrt time " + taskItem.Name + " failed....... \n" + error.ErrorMessage.ToString());
                    //MailHelper.ExceptionNotify("Running task fisrt time " + taskItem.Name + " failed", error.ErrorMessage.ToString(), ReportConfig.Instance.SmtpServer);

                    Console.WriteLine("Running task second time: " + taskItem.Name + ".......");
                    engine.Logger.Message("Running task second time: " + taskItem.Name + ".......");

                    error = engine.RunTask(taskItem, ReportConfig.SmtpServerManager.SmtpServer);

                    if (error.HasError)
                    {
                        MailHelper.ExceptionNotify("Running task second time " + taskItem.Name + " failed", error.ErrorMessage.ToString(), ReportConfig.SmtpServerManager.SmtpServer);
                    }
                }
            }
            else
            {
                engine.Logger.Error(string.Format("There is no task {0}. ", task));
            }

            this.Close();
        }
예제 #34
0
        public async Task InvokeAsync(HttpContext context)
        {
            if (_isPathValid(context) && CanHandleRequest(context))
            {
                var httpHelper = new HttpHelper(context, _serializer);

                try
                {
                    await HandleRequestAsync(httpHelper).ConfigureAwait(false);
                }
                catch (SyntaxException ex)
                {
                    IError error = ErrorBuilder.New()
                                   .SetMessage(ex.Message)
                                   .AddLocation(ex.Line, ex.Column)
                                   .SetCode(ErrorCodes.Execution.SyntaxError)
                                   .Build();

                    httpHelper.StatusCode = OK;
                    httpHelper.Result     = CreateError(ErrorHandler.Handle(error));
                }
                catch (QueryException ex)
                {
                    httpHelper.StatusCode = OK;
                    httpHelper.Result     = CreateError(ErrorHandler.Handle(ex.Errors));
                }
                catch (Exception ex)
                {
                    IError error = ErrorHandler.Handle(
                        ErrorBuilder.New()
                        .SetMessage(ex.Message)
                        .SetException(ex)
                        .Build());

                    httpHelper.StatusCode = BadRequest;
                    httpHelper.Result     = CreateError(error);
                }

                await httpHelper.WriteAsync().ConfigureAwait(false);
            }
            else if (Next != null)
            {
                await Next.Invoke(context).ConfigureAwait(false);
            }
        }
예제 #35
0
 public static void ReportGeneralError(
     GeneratorExecutionContext context,
     IError error,
     string title,
     string code)
 {
     context.ReportDiagnostic(
         Diagnostic.Create(
             new DiagnosticDescriptor(
                 id: code,
                 title: title,
                 messageFormat: $"An error occurred during generation: {error.Message}",
                 category: _category,
                 DiagnosticSeverity.Error,
                 isEnabledByDefault: true,
                 description: error.Message),
             Microsoft.CodeAnalysis.Location.None));
 }
예제 #36
0
        public void AddLocation_From_SyntaxNode()
        {
            // arrange
            var syntaxNode = new StringValueNode(
                new HotChocolate.Language.Location(1, 2, 3, 4),
                "abc",
                false);

            // act
            IError error = ErrorBuilder.New()
                           .SetMessage("bar")
                           .AddLocation(syntaxNode)
                           .Build();

            // assert
            Assert.Collection(error.Locations,
                              t => Assert.Equal(3, t.Line));
        }
예제 #37
0
        internal IReadOnlyDictionary <string, IReadOnlyList <IError> > GetErrorOutput()
        {
            var result = new Dictionary <string, IReadOnlyList <IError> >(_resultErrors.Count);

            foreach (var pair in _resultErrors)
            {
                var errors = new IError[pair.Value.Count];

                for (var i = 0; i < pair.Value.Count; ++i)
                {
                    errors[i] = _errorRegistry[pair.Value[i]];
                }

                result.Add(pair.Key, errors);
            }

            return(result);
        }
예제 #38
0
        private IError HandleException(IError error)
        {
            var buildError = error.Exception switch
            {
                Exception exception => HandleException(error, exception),
                _ => HandleException(error, error.Exception)
            };

            if (!int.TryParse(buildError.Code, out int code) || code <= 499)
            {
                return(buildError);
            }

            error.SetExtension("TraceId", _httpContextAccessor?.HttpContext?.TraceIdentifier);
            error.SetExtension("RequestId", _httpContextAccessor?.HttpContext?.Request.Headers["CorrelationId"].ToString());
            _logger.LogError(error.Exception, "{message}. Code: {code}. Path: {path}. GraphQLCode: {GraphQLCode}. ", error.Message, code, error.Path, error.Code);
            return(buildError);
        }
예제 #39
0
            public static async Task InsertErrorAsync(IError error)
            {
                // Create a command object identifying the stored procedure
                using (var cmd = new SqlCommand("sp_InsertErrorLog"))
                {
                    //
                    // Set the command object so it knows to execute a stored procedure
                    cmd.CommandType = CommandType.StoredProcedure;
                    //
                    // Add parameters to command, which will be passed to the stored procedure
                    if (error.Snapshot != null)
                        cmd.Parameters.AddWithValue("@ScreenCapture", error.Snapshot.ToBytes());


                    cmd.Parameters.AddWithValue("@ServerDateTime", error.ServerDateTime);
                    cmd.Parameters.AddWithValue("@Host", error.Host);
                    cmd.Parameters.AddWithValue("@User", error.User);
                    cmd.Parameters.AddWithValue("@IsHandled", error.IsHandled);
                    cmd.Parameters.AddWithValue("@Type", error.ErrorType);
                    cmd.Parameters.AddWithValue("@AppName", error.AppName);
                    cmd.Parameters.AddWithValue("@CurrentCulture", error.CurrentCulture);
                    cmd.Parameters.AddWithValue("@CLRVersion", error.ClrVersion);
                    cmd.Parameters.AddWithValue("@Message", error.Message);
                    cmd.Parameters.AddWithValue("@Source", error.Source ?? "");
                    cmd.Parameters.AddWithValue("@StackTrace", error.StackTrace);
                    cmd.Parameters.AddWithValue("@ModuleName", error.ModuleName);
                    cmd.Parameters.AddWithValue("@MemberType", error.MemberType);
                    cmd.Parameters.AddWithValue("@Method", error.Method);
                    cmd.Parameters.AddWithValue("@Processes", error.Processes);
                    cmd.Parameters.AddWithValue("@ErrorDateTime", error.ErrorDateTime);
                    cmd.Parameters.AddWithValue("@OS", error.OS);
                    cmd.Parameters.AddWithValue("@IPv4Address", error.IPv4Address);
                    cmd.Parameters.AddWithValue("@MACAddress", error.MacAddress);
                    cmd.Parameters.AddWithValue("@HResult", error.HResult);
                    cmd.Parameters.AddWithValue("@Line", error.LineColumn.Line);
                    cmd.Parameters.AddWithValue("@Column", error.LineColumn.Column);
                    cmd.Parameters.AddWithValue("@Duplicate", error.Duplicate);
                    cmd.Parameters.AddWithValue("@Data", error.Data);
                    //
                    // execute the command

                    await ConnectionManager.GetDefaultConnection().ExecuteNonQueryAsync(cmd);
                }
            }
예제 #40
0
        public ProxyError(IError error)
        {
            #region Initialize IError Properties

            Id = error.Id;
            IsHandled = error.IsHandled;
            ErrorDateTime = error.ErrorDateTime;
            ServerDateTime = error.ServerDateTime;
            HResult = error.HResult;
            AppName = error.AppName;
            ClrVersion = error.ClrVersion;
            CurrentCulture = error.CurrentCulture;
            ErrorType = error.ErrorType;
            Host = error.Host;
            IPv4Address = error.IPv4Address;
            MacAddress = error.MacAddress;
            MemberType = error.MemberType;
            Message = error.Message;
            Method = error.Method;
            ModuleName = error.ModuleName;
            OS = error.OS;
            Processes = error.Processes;
            Source = error.Source;
            StackTrace = error.StackTrace;
            User = error.User;
            LineColumn = error.LineColumn;
            Duplicate = error.Duplicate;
            Data = error.Data;

            #endregion

            #region Initialize Lazy<Image> Snapshot

            // Initialize by invoking a specific constructor on Order when Value property is accessed
            LazySnapshot = new Lazy<Image>(() => CacheController.SdfManager.GetSnapshot(Id));

            #endregion
        }
        private static async Task<Tuple<IError, bool>> TransmitOneError(IError error)
        {
            if (ErrorHandlingOption.EnableNetworkSending) // Server Connector to online or offline ?
            {
                try
                {
                    await SqlServerManager.InsertErrorAsync(error);
                }
                catch (AggregateException exp)
                {
                    // If an unhandled exception occurs during dataflow processing, all 
                    // exceptions are propagated through an AggregateException object.
                    ErrorHandlingOption.EnableNetworkSending = false;

                    exp.Handle(e =>
                    {
                        ErrorHandlingOption.AtSentState = false;
                        return true;
                    });
                }
            }
            // Mark the head of the pipeline as complete. The continuation tasks  
            // propagate completion through the pipeline as each part of the  
            // pipeline finishes.
            else
            {
                ErrorListenerTransformBlock.Complete();
                ErrorHandlingOption.AtSentState = false;
            }

            if (ErrorListenerTransformBlock.InputCount == 0)
                ErrorHandlingOption.AtSentState = false;
            //
            // Post to Acknowledge Action Block:
            return new Tuple<IError, bool>(error, ErrorHandlingOption.EnableNetworkSending);
        }
예제 #42
0
        public void SetErrorInterface(IError rIError)
        {
            //Delegate to our global object
            CError.Error = rIError;

            CError.WriteLine();
        }
예제 #43
0
 /// <summary>
 /// Init using a single error.
 /// </summary>
 public Exceptional(IError myIError)
     : this()
 {
     PushIError(myIError);
 }
예제 #44
0
 public bool Equals(IError x, IError y)
 {
     // Note: value types can't have derived classes, so we don't need
     return x != null && y != null && x.Equals(y);
 }
예제 #45
0
		/// <summary>
		/// Remove element from list.
		/// </summary>
		/// <param name="value"></param>
		public void Remove(IError value)
		{
			InnerList.Remove(value);
		}
예제 #46
0
		/// <summary>
		/// Copies the collection objects to a one-dimensional Array 
		/// instance beginning at the specified index.
		/// </summary>
		/// <param name="array"></param>
		/// <param name="index"></param>
		public void CopyTo(
			IError[] array,
			int index
			)
		{
			InnerList.CopyTo(array, index);
		}
예제 #47
0
        public bool Equals(IError other)
        {
            if (other == null) return false;

            // Note value types can't have derived classes, so we don't need
            return Id == other.Id;
        }
예제 #48
0
		/// <summary>
		/// Indicates whether a specified object is contained in the list.
		/// </summary>
		/// <param name="value"></param>
		/// <returns></returns>
		public bool Contains(IError value)
		{
			return InnerList.Contains(value);
		}
예제 #49
0
		/// <summary>
		/// Insert element to list.
		/// </summary>
		/// <param name="index"></param>
		/// <param name="value"></param>
		public void Insert(int index, IError value)
		{
			InnerList.Insert(index, value);
		}
예제 #50
0
 void _viewModel_ReportRunCompleted(IError obj)
 {
     if (obj.HasError)
     {
         this.lblMessage.Content = obj.ErrorMessage;
     }
     else
     {
         this.lblMessage.Content = "Report exported succeed.";
     }
 }
 internal CorruptedDatabaseException(IError error) : base(error)
 {
 }
 private static Exception CreateParseException(UnitError unitError, Lexeme lexeme, IError innerError = null)
 {
     return new UnitExpressionParseException(Error.From(unitError, lexeme, innerError));
 }
예제 #53
0
		/// <summary>
		/// Add element.
		/// </summary>
		/// <param name="value"></param>
		/// <returns></returns>
		public int Add(IError value)
		{
			return InnerList.Add(value);
		}
예제 #54
0
		/// <summary>
		/// Add an array of IError.
		/// </summary>
		/// <param name="items"></param>
		public void AddRange(IError[] items)
		{
			InnerList.AddRange(items);
		}
예제 #55
0
 /// <summary>
 /// Adds a single error.
 /// </summary>
 public Exceptional PushIError(IError myIError)
 {
     lock (this)
     {
         _IErrors.Push(myIError);
         return this;
     }
 }
예제 #56
0
 internal OdbRuntimeException(IError error)
     : base(
         string.Format("{0}\nError:{1}", Message1, error))
 {
 }
예제 #57
0
 void _viewModel_TaskRunCompleted(IError obj)
 {
     if (obj.HasError)
     {
         this.lblMessage.Content = "Task running failed.";
     }
     else
     {
         this.lblMessage.Content = "Task running succeed.";
     }
 }
예제 #58
0
 public Exception(SourcePosn sourcePosn, IError error)
 {
     SourcePosn = sourcePosn;
     Error = error;
 }
예제 #59
0
		/// <summary>
		/// Initializes a new instance containing the specified array 
		/// of IError objects
		/// </summary>
		/// <param name="value"></param>
		public ErrorSet(
			IError[] value
			)
		{
			AddRange(value);
		}
예제 #60
0
		/// <summary>
		/// Get index of an element.
		/// </summary>
		/// <param name="value"></param>
		/// <returns></returns>
		public int IndexOf(IError value)
		{
			return InnerList.IndexOf(value);
		}