Class WebfluxProblem

java.lang.Object
dmx.fun.spring.webflux.WebfluxProblem

@NullMarked public final class WebfluxProblem extends Object
Renders dmx-fun failures as RFC 7807 ProblemDetail responses (application/problem+json), so error handling in a fun-spring-webflux application produces a standard problem document instead of an ad-hoc body.

The problemDetail(HttpStatus, Function) factories return an ErrorHttpMapper / ThrowableHttpMapper you pass to WebfluxFun.fromResult(Mono, ErrorHttpMapper) / WebfluxFun.fromTry(Mono, ThrowableHttpMapper); fromValidated(Mono) renders accumulated validation failures as a 400 problem whose errors property lists every violation.

  • Method Details

    • problemDetail

      public static <E> ErrorHttpMapper<E> problemDetail(org.springframework.http.HttpStatus status, Function<? super E, String> detail)
      Returns an ErrorHttpMapper that renders a Result.Err as a ProblemDetail with the given status and a detail derived from the error value. Use it with WebfluxFun.fromResult(Mono, ErrorHttpMapper).
      Type Parameters:
      E - the domain error type
      Parameters:
      status - the HTTP status for the problem
      detail - derives the problem's human-readable detail from the error value
      Returns:
      an ErrorHttpMapper producing a problem-detail response
    • problemDetail

      public static ThrowableHttpMapper problemDetail(org.springframework.http.HttpStatus status)
      Returns a ThrowableHttpMapper that renders a Try.Failure as a ProblemDetail with the given status and the exception message as the detail. Use it with WebfluxFun.fromTry(Mono, ThrowableHttpMapper).
      Parameters:
      status - the HTTP status for the problem
      Returns:
      a ThrowableHttpMapper producing a problem-detail response
    • fromValidated

      public static <V,E> reactor.core.publisher.Mono<org.springframework.web.reactive.function.server.ServerResponse> fromValidated(reactor.core.publisher.Mono<Validated<NonEmptyList<E>, V>> source)
      Maps a Mono<Validated<NonEmptyList<E>, V>> to a response: Valid200 with the value, Invalid400 ProblemDetail whose errors property lists every accumulated error, empty → 404.
      Type Parameters:
      V - the value type
      E - the element type of the accumulated errors
      Parameters:
      source - the upstream validated value
      Returns:
      the HTTP response