carp.core-kotlin icon indicating copy to clipboard operation
carp.core-kotlin copied to clipboard

Domain exceptions for application services

Open Whathecode opened this issue 4 years ago • 2 comments

Broadly speaking every IllegalArgumentException that comes out of services right now should safely map to a 400 of corresponding web requests. The problem lies in when the underlying domain objects throw IllegalArgumentException's which do not map to illegal arguments of the service requests.

For that reason it would make sense to have domain specific IllegalArgumentException's for application services, so that we can uniformly map domain-specific exceptions to web errors. IllegalArgumentException's can then safely be mapped to 500's to address the former problem.

Whathecode avatar Aug 25 '21 08:08 Whathecode

After an initial attempt at implementing this, and an internal dialogue at iMotions we have decided to postpone this after the 1.0.0 release.

Whathecode avatar Sep 21 '21 13:09 Whathecode

A related problem arose recently. Ktor throws NoTransformationFoundException when it can't convert an incoming response to the expected type (since no transformation is registered). This extends from UnsupportedOperationException.

The same base exception is used in CARP core's ClientManager to indicate a retrieved deployment is not supported. This can cause an unexpected exception (the ktor one) to be handled when trying to handle the CARP exception.

Whathecode avatar Aug 29 '22 11:08 Whathecode