1 | package com.fwmotion.threescale.cms.exception; | |
2 | ||
3 | import com.redhat.threescale.rest.cms.model.Error; | |
4 | import jakarta.annotation.Nonnull; | |
5 | import jakarta.annotation.Nullable; | |
6 | ||
7 | import java.util.Optional; | |
8 | ||
9 | /** | |
10 | * Common base exception type for all 3scale CMS-related API exceptions | |
11 | */ | |
12 | public class ThreescaleCmsApiException extends ThreescaleCmsException { | |
13 | ||
14 | private final int httpStatus; | |
15 | private final Error apiError; | |
16 | ||
17 | public ThreescaleCmsApiException( | |
18 | int httpStatus, | |
19 | @Nullable Error apiError, | |
20 | @Nullable String message | |
21 | ) { | |
22 | super(message); | |
23 | this.httpStatus = httpStatus; | |
24 | this.apiError = apiError; | |
25 | } | |
26 | ||
27 | public ThreescaleCmsApiException( | |
28 | int httpStatus, | |
29 | @Nullable String message | |
30 | ) { | |
31 | this(httpStatus, null, message); | |
32 | } | |
33 | ||
34 | public ThreescaleCmsApiException( | |
35 | int httpStatus, | |
36 | @Nullable Error apiError | |
37 | ) { | |
38 | this(httpStatus, | |
39 | apiError, | |
40 | Optional.ofNullable(apiError) | |
41 | .map(Error::getError) | |
42 | .orElse(null)); | |
43 | } | |
44 | ||
45 | public ThreescaleCmsApiException( | |
46 | int httpStatus, | |
47 | @Nullable Error apiError, | |
48 | @Nullable String message, | |
49 | @Nonnull Throwable cause | |
50 | ) { | |
51 | super(message, cause); | |
52 | this.httpStatus = httpStatus; | |
53 | this.apiError = apiError; | |
54 | } | |
55 | ||
56 | public ThreescaleCmsApiException( | |
57 | int httpStatus, | |
58 | @Nullable String message, | |
59 | @Nonnull Throwable cause | |
60 | ) { | |
61 | this(httpStatus, null, message, cause); | |
62 | } | |
63 | ||
64 | public ThreescaleCmsApiException( | |
65 | int httpStatus, | |
66 | @Nullable Error apiError, | |
67 | @Nonnull Throwable cause | |
68 | ) { | |
69 | this(httpStatus, | |
70 | apiError, | |
71 | Optional.ofNullable(apiError) | |
72 | .map(Error::getError) | |
73 | .orElse(null), | |
74 | cause); | |
75 | } | |
76 | ||
77 | public int getHttpStatus() { | |
78 |
1
1. getHttpStatus : replaced int return with 0 for com/fwmotion/threescale/cms/exception/ThreescaleCmsApiException::getHttpStatus → NO_COVERAGE |
return httpStatus; |
79 | } | |
80 | ||
81 | @Nonnull | |
82 | public Optional<Error> getApiError() { | |
83 |
1
1. getApiError : replaced return value with Optional.empty for com/fwmotion/threescale/cms/exception/ThreescaleCmsApiException::getApiError → NO_COVERAGE |
return Optional.ofNullable(apiError); |
84 | } | |
85 | } | |
Mutations | ||
78 |
1.1 |
|
83 |
1.1 |