org.jreleaser.sdk.disco.RestAPIException Maven / Gradle / Ivy
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2023 The JReleaser authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jreleaser.sdk.disco;
import feign.Request;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
/**
* @author Andres Almiray
* @since 0.9.0
*/
public class RestAPIException extends RuntimeException {
private static final long serialVersionUID = -7270438109492904609L;
private final Request request;
private final int status;
private final String reason;
private final Map> headers;
public RestAPIException(int status, String reason) {
this(null, status, reason, Collections.emptyMap());
}
public RestAPIException(Request request, int status, String reason, Map> headers) {
this.request = request;
this.status = status;
this.reason = reason;
this.headers = headers;
}
public Request getRequest() {
return request;
}
public int getStatus() {
return status;
}
public String getReason() {
return reason;
}
public Map> getHeaders() {
return headers;
}
public boolean isNotFound() {
return 404 == status;
}
public boolean isForbidden() {
return 403 == status;
}
}