Skip to content

Improve IActionResult Error API #356

@jaredcnance

Description

@jaredcnance

The current API is less than desirable:

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");

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions