Search in sources :

Example 1 with ExceptionType

use of uk.gov.ida.common.ExceptionType in project verify-hub by alphagov.

the class InvalidSessionStateExceptionMapper method handleException.

@Override
public Response handleException(InvalidSessionStateException exception) {
    UUID errorId = UUID.randomUUID();
    LOG.warn(LogFormatter.formatLog(errorId, exception.getMessage()), exception);
    eventLogger.logErrorEvent(errorId, getSessionId().orElse(SessionId.SESSION_ID_DOES_NOT_EXIST_YET), exception.getMessage());
    ExceptionType type = getExceptionType(exception);
    ErrorStatusDto entity = ErrorStatusDto.createAuditedErrorStatus(errorId, type, exception.getMessage());
    return Response.status(Response.Status.BAD_REQUEST).entity(entity).build();
}
Also used : ExceptionType(uk.gov.ida.common.ExceptionType) ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) UUID(java.util.UUID)

Example 2 with ExceptionType

use of uk.gov.ida.common.ExceptionType in project verify-hub by alphagov.

the class SamlEngineExceptionMapperTest method shouldPassthroughErrorIdAndExceptionType.

@Test
public void shouldPassthroughErrorIdAndExceptionType() throws Exception {
    UUID errorId = UUID.randomUUID();
    final ExceptionType exceptionType = ExceptionType.IDA_SOAP;
    ApplicationException applicationException = createUnauditedException(exceptionType, errorId);
    final Response response = samlEngineExceptionMapper.toResponse(applicationException);
    assertThat(response.hasEntity()).isTrue();
    ErrorStatusDto errorStatusDto = (ErrorStatusDto) response.getEntity();
    assertThat(errorStatusDto.getErrorId()).isEqualTo(errorId);
    assertThat(errorStatusDto.getExceptionType()).isEqualTo(exceptionType);
    checkLogLevel(applicationException.getExceptionType().getLevel());
}
Also used : Response(javax.ws.rs.core.Response) ExceptionType(uk.gov.ida.common.ExceptionType) ApplicationException(uk.gov.ida.exceptions.ApplicationException) ErrorStatusDto(uk.gov.ida.common.ErrorStatusDto) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Aggregations

UUID (java.util.UUID)2 ErrorStatusDto (uk.gov.ida.common.ErrorStatusDto)2 ExceptionType (uk.gov.ida.common.ExceptionType)2 Response (javax.ws.rs.core.Response)1 Test (org.junit.jupiter.api.Test)1 ApplicationException (uk.gov.ida.exceptions.ApplicationException)1