
com.github.phillipkruger.apiee.providers.NotAuthorizedExceptionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apiee-providers Show documentation
Show all versions of apiee-providers Show documentation
Some general Exception mappers
The newest version!
package com.github.phillipkruger.apiee.providers;
import jakarta.ejb.AccessLocalException;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
/**
* Translate Java entity not found exceptions to HTTP response
* @author Phillip Kruger ([email protected])
*/
@Provider
public class NotAuthorizedExceptionMapper implements ExceptionMapper {
@Override
@Produces(MediaType.APPLICATION_JSON)
public Response toResponse(AccessLocalException accessLocalException) {
return Response.status(Response.Status.UNAUTHORIZED).header(REASON,accessLocalException.getMessage()).build();
}
private static final String REASON = "reason";
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy