public static Task HandleExceptionAsync(HttpContext context, Exception e) { context.Response.ContentType = "application/json"; if (e is RepositoryException) { context.Response.StatusCode = (int)HttpStatusCode.OK; return(context.Response.WriteAsync(ResponseModel.CreateError(e.Message).ToString())); } else { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(context.Response.WriteAsync("Internal Server Error.")); } }