GlobalExceptionHandler.java

1
package org.sanmibuh.framework.rest;
2
3
import lombok.extern.slf4j.Slf4j;
4
import org.sanmibuh.ddd.domain.AggregateNotFoundException;
5
import org.sanmibuh.ddd.domain.DomainException;
6
import org.sanmibuh.ddd.domain.IntegrationException;
7
import org.sanmibuh.ddd.domain.TransientIntegrationException;
8
import org.springframework.http.HttpStatus;
9
import org.springframework.http.ProblemDetail;
10
import org.springframework.web.bind.annotation.ExceptionHandler;
11
import org.springframework.web.bind.annotation.RestControllerAdvice;
12
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
13
14
@Slf4j
15
@RestControllerAdvice
16
public final class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
17
18
  @ExceptionHandler(DomainException.class)
19
  public ProblemDetail handleDomainException(final DomainException ex) {
20
    final var detail = ProblemDetail.forStatus(HttpStatus.BAD_REQUEST);
21 1 1. handleDomainException : removed call to org/springframework/http/ProblemDetail::setDetail → KILLED
    detail.setDetail(ex.getMessage());
22
23 1 1. handleDomainException : replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleDomainException → KILLED
    return detail;
24
  }
25
26
  @ExceptionHandler(AggregateNotFoundException.class)
27
  public ProblemDetail handleAggregateNotFoundException(final AggregateNotFoundException ex) {
28
    final var detail = ProblemDetail.forStatus(HttpStatus.NOT_FOUND);
29 1 1. handleAggregateNotFoundException : removed call to org/springframework/http/ProblemDetail::setDetail → KILLED
    detail.setDetail(ex.getMessage());
30
31 1 1. handleAggregateNotFoundException : replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleAggregateNotFoundException → KILLED
    return detail;
32
  }
33
34
  @ExceptionHandler(TransientIntegrationException.class)
35
  public ProblemDetail handleTransientIntegrationException(final TransientIntegrationException ex) {
36
    log.warn("Transient integration failure", ex);
37 1 1. handleTransientIntegrationException : replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleTransientIntegrationException → KILLED
    return ProblemDetail.forStatus(HttpStatus.SERVICE_UNAVAILABLE);
38
  }
39
40
  @ExceptionHandler(IntegrationException.class)
41
  public ProblemDetail handleIntegrationException(final IntegrationException ex) {
42
    log.error("Integration failure", ex);
43 1 1. handleIntegrationException : replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleIntegrationException → KILLED
    return ProblemDetail.forStatus(HttpStatus.INTERNAL_SERVER_ERROR);
44
  }
45
46
  @ExceptionHandler(Exception.class)
47
  public ProblemDetail handleUnexpectedException(final Exception ex) {
48
    log.error("Unexpected error", ex);
49 1 1. handleUnexpectedException : replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleUnexpectedException → KILLED
    return ProblemDetail.forStatus(HttpStatus.INTERNAL_SERVER_ERROR);
50
  }
51
}

Mutations

21

1.1
Location : handleDomainException
Killed by : org.sanmibuh.framework.rest.GlobalExceptionHandlerTest.[engine:junit-jupiter]/[class:org.sanmibuh.framework.rest.GlobalExceptionHandlerTest]/[method:should_returnBadRequestWithDetail_whenDomainExceptionIsThrown()]
removed call to org/springframework/http/ProblemDetail::setDetail → KILLED

23

1.1
Location : handleDomainException
Killed by : org.sanmibuh.framework.rest.GlobalExceptionHandlerTest.[engine:junit-jupiter]/[class:org.sanmibuh.framework.rest.GlobalExceptionHandlerTest]/[method:should_returnBadRequestWithDetail_whenDomainExceptionIsThrown()]
replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleDomainException → KILLED

29

1.1
Location : handleAggregateNotFoundException
Killed by : org.sanmibuh.framework.rest.GlobalExceptionHandlerTest.[engine:junit-jupiter]/[class:org.sanmibuh.framework.rest.GlobalExceptionHandlerTest]/[method:should_returnNotFound_whenAggregateNotFoundExceptionIsThrown()]
removed call to org/springframework/http/ProblemDetail::setDetail → KILLED

31

1.1
Location : handleAggregateNotFoundException
Killed by : org.sanmibuh.framework.rest.GlobalExceptionHandlerTest.[engine:junit-jupiter]/[class:org.sanmibuh.framework.rest.GlobalExceptionHandlerTest]/[method:should_returnNotFound_whenAggregateNotFoundExceptionIsThrown()]
replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleAggregateNotFoundException → KILLED

37

1.1
Location : handleTransientIntegrationException
Killed by : org.sanmibuh.framework.rest.GlobalExceptionHandlerTest.[engine:junit-jupiter]/[class:org.sanmibuh.framework.rest.GlobalExceptionHandlerTest]/[method:should_returnServiceUnavailable_whenTransientIntegrationExceptionIsThrown()]
replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleTransientIntegrationException → KILLED

43

1.1
Location : handleIntegrationException
Killed by : org.sanmibuh.framework.rest.GlobalExceptionHandlerTest.[engine:junit-jupiter]/[class:org.sanmibuh.framework.rest.GlobalExceptionHandlerTest]/[method:should_returnInternalServerError_whenIntegrationExceptionIsThrown()]
replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleIntegrationException → KILLED

49

1.1
Location : handleUnexpectedException
Killed by : org.sanmibuh.framework.rest.GlobalExceptionHandlerTest.[engine:junit-jupiter]/[class:org.sanmibuh.framework.rest.GlobalExceptionHandlerTest]/[method:should_return500_whenHandlerNotFoundExceptionIsThrown()]
replaced return value with null for org/sanmibuh/framework/rest/GlobalExceptionHandler::handleUnexpectedException → KILLED

Active mutators

Tests examined


Report generated by PIT 1.30.0 support