• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FIWARE / contract-management / #26

28 Jan 2025 10:59AM UTC coverage: 0.982% (-0.6%) from 1.629%
#26

push

web-flow
Merge pull request #3 from FIWARE/tpp-integration

Tpp integration

99 of 500 new or added lines in 14 files covered. (19.8%)

4 existing lines in 3 files now uncovered.

281 of 28625 relevant lines covered (0.98%)

0.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/fiware/iam/exception/CatchAllExceptionHandler.java
1
package org.fiware.iam.exception;
2

3
import io.micronaut.context.annotation.Requires;
4
import io.micronaut.http.HttpRequest;
5
import io.micronaut.http.HttpResponse;
6
import io.micronaut.http.HttpStatus;
7
import io.micronaut.http.annotation.Produces;
8
import io.micronaut.http.server.exceptions.ExceptionHandler;
9
import jakarta.inject.Singleton;
10
import lombok.extern.slf4j.Slf4j;
11
import org.fiware.iam.tmforum.productorder.model.ErrorVO;
12

13
import java.time.format.DateTimeParseException;
14

15
/**
16
 * Handler to catch and log all unexpected exceptions and translate them into a proper 500 response.
17
 */
18
@Produces
19
@Singleton
20
@Requires(classes = {Exception.class, ExceptionHandler.class})
UNCOV
21
@Slf4j
×
UNCOV
22
public class CatchAllExceptionHandler implements ExceptionHandler<Exception, HttpResponse<ErrorVO>> {
×
23

24
        @Override
25
        public HttpResponse<ErrorVO> handle(HttpRequest request, Exception exception) {
NEW
26
                log.warn("Received unexpected exception {} for request {}.", exception.getMessage(), request.getUri(), exception);
×
NEW
27
                if (exception instanceof DateTimeParseException dateTimeParseException) {
×
NEW
28
                        return HttpResponse.status(HttpStatus.BAD_REQUEST)
×
NEW
29
                                        .body(
×
NEW
30
                                                        new ErrorVO().status(HttpStatus.BAD_REQUEST.toString())
×
NEW
31
                                                                        .reason(HttpStatus.BAD_REQUEST.getReason())
×
NEW
32
                                                                        .message(String.format("Request could not be answered due to an invalid date: %s.",
×
NEW
33
                                                                                        dateTimeParseException.getParsedString())));
×
34
                }
NEW
35
                if (exception instanceof TMForumException tmForumException) {
×
NEW
36
                        return HttpResponse.status(HttpStatus.BAD_GATEWAY)
×
NEW
37
                                        .body(
×
NEW
38
                                                        new ErrorVO().status(HttpStatus.BAD_GATEWAY.toString())
×
NEW
39
                                                                        .reason(HttpStatus.BAD_GATEWAY.getReason())
×
NEW
40
                                                                        .message(String.format("Request could not be answered due to error in downstream tmforum service: %s.",
×
NEW
41
                                                                                        tmForumException.getMessage())));
×
42
                }
NEW
43
                if (exception instanceof TrustedIssuersException trustedIssuersException) {
×
NEW
44
                        return HttpResponse.status(HttpStatus.BAD_GATEWAY)
×
NEW
45
                                        .body(
×
NEW
46
                                                        new ErrorVO().status(HttpStatus.BAD_GATEWAY.toString())
×
NEW
47
                                                                        .reason(HttpStatus.BAD_GATEWAY.getReason())
×
NEW
48
                                                                        .message(String.format("Request could not be answered due to error in downstream trusted issuers list service: %s.",
×
NEW
49
                                                                                        trustedIssuersException.getMessage())));
×
50
                }
NEW
51
                if (exception instanceof RainbowException rainbowException) {
×
NEW
52
                        return HttpResponse.status(HttpStatus.BAD_GATEWAY)
×
NEW
53
                                        .body(
×
NEW
54
                                                        new ErrorVO().status(HttpStatus.BAD_GATEWAY.toString())
×
NEW
55
                                                                        .reason(HttpStatus.BAD_GATEWAY.getReason())
×
NEW
56
                                                                        .message(String.format("Request could not be answered due to error in downstream rainbow service: %s.",
×
NEW
57
                                                                                        rainbowException.getMessage())));
×
58
                }
NEW
59
                if (exception instanceof IllegalArgumentException illegalArgumentException) {
×
NEW
60
                        return HttpResponse.status(HttpStatus.BAD_REQUEST)
×
NEW
61
                                        .body(
×
NEW
62
                                                        new ErrorVO().status(HttpStatus.BAD_REQUEST.toString())
×
NEW
63
                                                                        .reason(HttpStatus.BAD_REQUEST.getReason())
×
NEW
64
                                                                        .message(String.format(illegalArgumentException.getMessage())));
×
65
                }
NEW
66
                return HttpResponse.status(HttpStatus.INTERNAL_SERVER_ERROR)
×
NEW
67
                                .body(new ErrorVO().status(HttpStatus.INTERNAL_SERVER_ERROR.toString())
×
NEW
68
                                                .reason(HttpStatus.INTERNAL_SERVER_ERROR.getReason())
×
NEW
69
                                                .message("Request could not be answered due to an unexpected internal error."));
×
70
        }
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc