You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, the services are throwing exceptions that are being caught in a generic middleware. The services are also able to specify which HTTP status code they want to return to. Whilst this works, I would prefer that the services are agnostic of any HTTP responses and that exceptions are only thrown when something exceptional happens.
Proposed changes:
Have each command/query return an object with a base response.
For example it could look something like:
public class BaseResult
{
public bool Success {get; set;}
public string Message {get; set;}
public string Description {get; set;}
public ValidationFailures FailureReason {get; set;}
}
public enum ValidationFailures
{
InvalidRequest,
Unauthorised
}
Controllers are then responsible (as they should be) for returning the correct responses.
The exception middleware should only then be used for unhandled exceptions
The text was updated successfully, but these errors were encountered:
At the moment, the services are throwing exceptions that are being caught in a generic middleware. The services are also able to specify which HTTP status code they want to return to. Whilst this works, I would prefer that the services are agnostic of any HTTP responses and that exceptions are only thrown when something exceptional happens.
Proposed changes:
For example it could look something like:
The text was updated successfully, but these errors were encountered: