instead of the expected Left[ErrorInfo,Unit] . My endpoint looks like
ndpont
.get
.in("_ready")
.in(query[List[String]]("checked"))
.out(statusCode(StatusCode.Ok))
.errorOut(
oneOf[ErrorInfo](
oneOfVariant(statusCode(StatusCode.InternalServerError).and(jsonBody[ReadyCheckFailed])), //Failed a ready check oneOfVariant(statusCode(StatusCode.NotFound).and(jsonBody[NotFound])), //404 when there's no /_ready oneOfVariant(statusCode(StatusCode.Unauthorized).and(jsonBody[Unauthorized])), //sometimes a 401 when there's no /_ready oneOfVariant(statusCode(StatusCode.InternalServerError).and(jsonBody[InternalServerError])), //Some other 500
)
)
with sealed trait ErrorInfo case class ReadyCheckFailed(failedChecks:List[String]) extends ErrorInfo case class NotFound(what: String) extends ErrorInfo
case class Unauthorized(realm: String) extends ErrorInfo
case class InternalServerError(msg: String) extends ErrorInfo
So this was when using the endpoint as a client, and receiving a 500 response with a non-JSON body? Maybe there is something we could do to make the errors better (or richer).
The scala ecosystem is maybe settling on throwing Exceptions - because so many things can go wrong - and returning Either[BrokenThingsYouThoughtAbout, WhatYouWant] s . Bill Venners predicted that at NEScala in 2015 “The Good, The Bad, and The Ugly” .
It looks like infallibleEndpoint will give me the ugly Exceptions I want. That might be a better starting point for URLs in many cases. I sure didn’t find it on my own.
endpoint is going to hide the Ugly. That probably can’t change until Tapir 2.x; it breaking existing code. I don’t think you should touch it.
Maybe add a paragraph about infallibleEndpoint at the start of error handling in the docs?