Exemplo n.º 1
0
        private static string HandleExceptionAsync(HttpContext context, Exception exception)
        {
            var errors   = ExceptionUtility.GetErrors(exception);
            var response = CreateErrorResponse(errors);

            context.Response.ContentType = "application/json";
            context.Response.StatusCode  = (int)HttpStatusCode.InternalServerError;
            return(response);
        }
Exemplo n.º 2
0
        private static string CreateErrorResponse(object data)
        {
            if (data == null)
            {
                var errors        = ExceptionUtility.GetErrors();
                var errorResponse = new ErrorResponse(errors);
                return(Serialize(errorResponse));
            }

            object[] messages     = { data };
            var      errorMessage = new {
                errors = messages
            };

            return(Serialize(errorMessage));
        }