io.quarkus.code.rest.exceptions.ExceptionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-quarkus Show documentation
Show all versions of code-quarkus Show documentation
Customize a Web Interface to generate Quarkus starter projects.
package io.quarkus.code.rest.exceptions;
import io.quarkus.logging.Log;
import io.quarkus.runtime.LaunchMode;
import io.smallrye.mutiny.Uni;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.Priorities;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import org.jboss.resteasy.reactive.server.ServerExceptionMapper;
@ApplicationScoped
public class ExceptionMapper {
@ServerExceptionMapper(priority = Priorities.USER + 2)
public Uni mapException(Throwable exception) {
if (Log.isDebugEnabled() || LaunchMode.current().isDevOrTest()) {
Log.error(exception.getMessage(), exception);
}
if (exception instanceof WebApplicationException) {
return Uni.createFrom().item(((WebApplicationException) exception).getResponse());
}
return Uni.createFrom().item(Response.serverError().build());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy