I'm looking at using hexagonal/ports & adapters design in some code I'm working on and for the most part I'm happy but there is one part that I'm struggling with which how to handle the need for different return values from a single call.I'll use an example to better illustrate, this is pseudo code so names aren't represntative of real code.If I have a domain service which has a method AddEntity I can have 3 returns:Newly added objectInvalid DataEntity already existsThe adapter that uses this service will then take the return and will send the data in the object back (it may transform it to a view model first).In C# the adapter maybe a WebApi controller with code something like this:public IHttpActionResult Post(DataViewModel entityData){    var item = this.service.AddEntity(entityData.Name, entityData.Description);    if (item == null)     {        return this.StatusCode(HttpStatusCode.Conflict);    }    var viewModel = Mapper.Map<EntityDTO, DataViewModel>(item);    return this.Created(this.Url.Link(DefaultApi, new { controller = Entity, id = viewModel.Id }), viewModel);}The problem as you can see is at the moment it can only deal with 2 returns, either it gets the entityDTO which it maps and returns to the client or it gets null and just returns a Conflict HttpStatus code.What I'm trying to work out is how I could get back to the adapter, controller in example above, is either the object or one of the two messages.The approaches I've considered are:extending the entityDTO class to have additional information which would allow me to pass something indicating a problem (an enum maybe?) raising typed exceptions and handling the exceptionsraising eventsif I used the enum then the controller code would look something like this:public IHttpActionResult Post(DataViewModel entityData){    var item = this.service.AddEntity(entityData.Name, entityData.Description);    if(item.result == Result.Conflict)    {        return this.StatusCode(HttpStatusCode.Conflict);    }    if (item.result == Result.Invalid)     {        return this.StatusCode(HttpStatusCode.Invalid);    }    var viewModel = Mapper.Map<EntityDTO, DataViewModel>(item);    return this.Created(this.Url.Link(DefaultApi, new { controller = Entity, id = viewModel.Id }), viewModel);}Of these extending the DTO seems the least bad option but I'm unsure if I've just missed something in the pattern which gives an easy way to do this.Is there any specific way to do this I've missed? or is one of the options for sorting this I mentioned above a better way than the others?
Hexagonal architecure - handle multiple returns from domain logic
design;architectural patterns