Пример #1
0
        public Task HandleExceptionAsync(HttpContext context, IntrneuronExceptionHandlerOptions options)
        {
            context.Response.ContentType = "application/json";
            context.Response.StatusCode  = this.dbEx.ErrorCode;
            var errorData    = ExceptionError.GetExceptionErrorAsJSON(dbEx.ErrorId, dbEx.ErrorResponseMessage);
            var responseTask = context.Response.WriteAsync(errorData);

            if (options != null)
            {
                options.OnExceptionHandlingComplete?.Invoke(this.dbEx, dbEx.ErrorId);
            }
            return(responseTask);
        }
        public Task HandleExceptionAsync(HttpContext context, IntrneuronExceptionHandlerOptions options)
        {
            var errorId = Guid.NewGuid().ToString();
            var errorResponseMessage = $"Error fetching data from database. Please check the error log with ID: {errorId} for more details";

            context.Response.ContentType = "application/json";
            context.Response.StatusCode  = 500;

            var errorData = ExceptionError.GetExceptionErrorAsJSON(errorId, errorResponseMessage);

            var responseTask = context.Response.WriteAsync(errorData);

            if (options != null)
            {
                options.OnExceptionHandlingComplete?.Invoke(this.ex, errorId);
            }
            return(responseTask);
        }