throwNotFoundIfEmpty
Throws NotFoundResourceException if the Mono is empty.
This extension function converts an empty Mono into an error signal containing a NotFoundResourceException. It's useful for handling cases where a resource lookup returns no results.
Example usage:
val resource = repository.findById(id)
.throwNotFoundIfEmpty("Resource with ID $id not found")Return
a Mono that signals NotFoundResourceException if empty
Parameters
the error message for the exception
the underlying cause, if any
Type Parameters
the element type
Throws NotFoundResourceException if the Flux is empty.
This extension function converts an empty Flux into an error signal containing a NotFoundResourceException. It's useful for handling cases where a collection lookup returns no results.
Example usage:
val resources = repository.findAll()
.throwNotFoundIfEmpty("No resources found")Return
a Flux that signals NotFoundResourceException if empty
Parameters
the error message for the exception
the underlying cause, if any
Type Parameters
the element type