-
-
Notifications
You must be signed in to change notification settings - Fork 159
Closed
Description
The current API is less than desirable:
JsonApiDotNetCore/src/JsonApiDotNetCore/Controllers/JsonApiControllerMixin.cs
Lines 15 to 26 in f68efb4
protected IActionResult Error(Error error) | |
{ | |
var errorCollection = new ErrorCollection | |
{ | |
Errors = new List<Error> { error } | |
}; | |
return new ObjectResult(errorCollection) | |
{ | |
StatusCode = error.StatusCode | |
}; | |
} |
results in calls like:
return Error(new Error(...));
I think it would be better if it there were just a method on the Error
type that provided it as an IActionResult
:
return new Error(500, "Could not compute.").AsActionResult();
Or the controller method could copy the Error
constructor signature:
return Error(500, "Could not compute");