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

jreleaser / jreleaser / #551

01 Nov 2025 04:25PM UTC coverage: 48.251% (+0.3%) from 47.949%
#551

push

github

aalmiray
build: Update jdks to Java 25

26015 of 53916 relevant lines covered (48.25%)

0.48 hits per line

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

44.44
/sdks/jreleaser-java-sdk-commons/src/main/java/org/jreleaser/sdk/commons/RestAPIException.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 *
4
 * Copyright 2020-2025 The JReleaser authors.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     https://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
package org.jreleaser.sdk.commons;
19

20
import feign.Request;
21

22
import java.util.Collection;
23
import java.util.Collections;
24
import java.util.Map;
25

26
import static org.jreleaser.util.StringUtils.isNotBlank;
27

28
/**
29
 * @author Andres Almiray
30
 * @since 0.2.0
31
 */
32
public class RestAPIException extends RuntimeException {
33
    private static final long serialVersionUID = 1046140359716555856L;
34

35
    private final Request request;
36
    private final int status;
37
    private final String reason;
38
    private final String body;
39
    private final Map<String, Collection<String>> headers;
40

41
    public RestAPIException(int status, Throwable cause) {
42
        this(null, status, "", null, Collections.emptyMap(), cause);
×
43
    }
×
44

45
    public RestAPIException(int status, String reason, Throwable cause) {
46
        this(null, status, reason, null, Collections.emptyMap(), cause);
×
47
    }
×
48

49
    public RestAPIException(int status, String reason) {
50
        this(null, status, reason, Collections.emptyMap());
×
51
    }
×
52

53
    public RestAPIException(int status, String reason, String body) {
54
        this(null, status, reason, body, Collections.emptyMap());
×
55
    }
×
56

57
    public RestAPIException(Request request, int status, String reason, Map<String, Collection<String>> headers) {
58
        this(request, status, reason, "", headers);
×
59
    }
×
60

61
    public RestAPIException(Request request, int status, String reason, String body, Map<String, Collection<String>> headers) {
62
        this(request, status, reason, body, headers, null);
1✔
63
    }
1✔
64

65
    public RestAPIException(Request request, int status, String reason, String body, Map<String, Collection<String>> headers, Throwable cause) {
66
        super(status + ": " + reason + (isNotBlank(body) ? System.lineSeparator() + body : ""), cause);
1✔
67
        this.request = request;
1✔
68
        this.status = status;
1✔
69
        this.reason = reason;
1✔
70
        this.body = body;
1✔
71
        this.headers = headers;
1✔
72
    }
1✔
73

74
    public Request getRequest() {
75
        return request;
×
76
    }
77

78
    public int getStatus() {
79
        return status;
1✔
80
    }
81

82
    public String getReason() {
83
        return reason;
1✔
84
    }
85

86
    public String getBody() {
87
        return body;
×
88
    }
89

90
    public Map<String, Collection<String>> getHeaders() {
91
        return headers;
×
92
    }
93

94
    public boolean isNotFound() {
95
        return 404 == status;
1✔
96
    }
97

98
    public boolean isForbidden() {
99
        return 403 == status;
×
100
    }
101

102
    public boolean isUnprocessableEntity() {
103
        return 422 == status;
×
104
    }
105
}
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