Is there a way I can define errorOutVariants in a single place that can be reused on multiple endpoints?
So I have for all my endpoints some kind of authorization error variant, bad requests, server errors that are in all of the endpoints. I also have a specific error out variant for each endpoints.
So I would like to be able to do something like this:
val commonVariants = List(oneOfVariant(BadRequestVariant),
oneOfVariant(AuthorizationErrorVariant),
oneOfDefaultVariant(DefaultErrorVariant))
securedEndpoint.get
.blahblahblah
.errorOutVariants(
oneOfVariant(statusCode(StatusCode.NotFound).and(jsonBody[NotFound]))
)
.errorOutVariants(commonVariants)
Potentially even better is when I define my PartialServerEndpoint for authentication, since all my endpoints use that, be able to define that there.
I had tried making it so that securedEndpoint.errorOutVariants() had all my common error outs, but I got runtime errors about them not being defined when I called the endpoint.