private static Task HandleExceptionAsync(DbUpdateException ex, HttpContext context, bool isDevelopment = false)
        {
            var errorOutput = new ApiErrorOutput
            {
                Title  = "Database violation error.",
                Status = (int)HttpStatusCode.Conflict
            };
            const string dbProductionMessage =
                "Some constraints were violated. Please contact system's administrators.";
            var messages = new[] { isDevelopment?ex.Message : dbProductionMessage };

            errorOutput.AddErrorEntry("Database", messages);
            return(WriteCustomOutputAsync(errorOutput, context));
        }
        private static Task HandleExceptionAsync(Exception ex, HttpContext context, bool isDevelopment = false)
        {
            var errorOutput = new ApiErrorOutput
            {
                Title  = "Unexpected Execution error.",
                Status = (int)HttpStatusCode.InternalServerError
            };
            const string executionProductionMessage =
                "Sorry! A failure occurred during request. Please contact system's administrators.";
            var messages = isDevelopment
                                ? ExtractExceptionMessages(ex).ToArray()
                                : new[] { executionProductionMessage };

            errorOutput.AddErrorEntry("Execution", messages);
            return(WriteCustomOutputAsync(errorOutput, context));
        }