KEYCLOAK-1360 ModelExceptionMapper logges the exception
This commit is contained in:
parent
e1adceeb85
commit
bcd607a1ee
1 changed files with 6 additions and 0 deletions
|
@ -4,6 +4,8 @@ import javax.ws.rs.core.Context;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.ExceptionMapper;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
import org.keycloak.messages.MessagesProvider;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.ModelException;
|
||||
|
@ -15,6 +17,8 @@ import org.keycloak.services.ErrorResponse;
|
|||
@Provider
|
||||
public class ModelExceptionMapper implements ExceptionMapper<ModelException> {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ModelExceptionMapper.class);
|
||||
|
||||
@Context
|
||||
private KeycloakSession session;
|
||||
|
||||
|
@ -22,6 +26,8 @@ public class ModelExceptionMapper implements ExceptionMapper<ModelException> {
|
|||
public Response toResponse(ModelException ex) {
|
||||
String message = session.getProvider(MessagesProvider.class, "admin")
|
||||
.getMessage(ex.getMessage(), ex.getParameters());
|
||||
|
||||
logger.error(message, ex);
|
||||
return ErrorResponse.error(message, Response.Status.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue