mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-13 00:11:22 +00:00
136 lines
7.0 KiB
HTML
136 lines
7.0 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>HttpException.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub API for Java</a> > <a href="index.source.html" class="el_package">org.kohsuke.github</a> > <span class="el_source">HttpException.java</span></div><h1>HttpException.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
|
|
|
|
import java.io.IOException;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
|
|
import javax.annotation.CheckForNull;
|
|
|
|
/**
|
|
* {@link IOException} for http exceptions because {@link HttpURLConnection} throws un-discerned {@link IOException} and
|
|
* it can help to know the http response code to decide how to handle an http exceptions.
|
|
*
|
|
* @author <a href="mailto:cleclerc@cloudbees.com">Cyrille Le Clerc</a>
|
|
*/
|
|
public class HttpException extends GHIOException {
|
|
static final long serialVersionUID = 1L;
|
|
|
|
private final int responseCode;
|
|
private final String responseMessage;
|
|
private final String url;
|
|
|
|
/**
|
|
* Instantiates a new Http exception.
|
|
*
|
|
* @param message
|
|
* The detail message (which is saved for later retrieval by the {@link #getMessage()} method)
|
|
* @param responseCode
|
|
* Http response code. {@code -1} if no code can be discerned.
|
|
* @param responseMessage
|
|
* Http response message
|
|
* @param url
|
|
* The url that was invoked
|
|
* @see HttpURLConnection#getResponseCode() HttpURLConnection#getResponseCode()
|
|
* @see HttpURLConnection#getResponseMessage() HttpURLConnection#getResponseMessage()
|
|
*/
|
|
public HttpException(String message, int responseCode, String responseMessage, String url) {
|
|
<span class="fc" id="L37"> super(message);</span>
|
|
<span class="fc" id="L38"> this.responseCode = responseCode;</span>
|
|
<span class="fc" id="L39"> this.responseMessage = responseMessage;</span>
|
|
<span class="fc" id="L40"> this.url = url;</span>
|
|
<span class="fc" id="L41"> }</span>
|
|
|
|
/**
|
|
* Instantiates a new Http exception.
|
|
*
|
|
* @param message
|
|
* The detail message (which is saved for later retrieval by the {@link #getMessage()} method)
|
|
* @param responseCode
|
|
* Http response code. {@code -1} if no code can be discerned.
|
|
* @param responseMessage
|
|
* Http response message
|
|
* @param url
|
|
* The url that was invoked
|
|
* @param cause
|
|
* The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
|
|
* permitted, and indicates that the cause is nonexistent or unknown.)
|
|
* @see HttpURLConnection#getResponseCode() HttpURLConnection#getResponseCode()
|
|
* @see HttpURLConnection#getResponseMessage() HttpURLConnection#getResponseMessage()
|
|
*/
|
|
public HttpException(String message, int responseCode, String responseMessage, String url, Throwable cause) {
|
|
<span class="fc" id="L61"> super(message, cause);</span>
|
|
<span class="fc" id="L62"> this.responseCode = responseCode;</span>
|
|
<span class="fc" id="L63"> this.responseMessage = responseMessage;</span>
|
|
<span class="fc" id="L64"> this.url = url;</span>
|
|
<span class="fc" id="L65"> }</span>
|
|
|
|
/**
|
|
* Instantiates a new Http exception.
|
|
*
|
|
* @param responseCode
|
|
* Http response code. {@code -1} if no code can be discerned.
|
|
* @param responseMessage
|
|
* Http response message
|
|
* @param url
|
|
* The url that was invoked
|
|
* @param cause
|
|
* The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
|
|
* permitted, and indicates that the cause is nonexistent or unknown.)
|
|
* @see HttpURLConnection#getResponseCode() HttpURLConnection#getResponseCode()
|
|
* @see HttpURLConnection#getResponseMessage() HttpURLConnection#getResponseMessage()
|
|
*/
|
|
public HttpException(int responseCode, String responseMessage, String url, Throwable cause) {
|
|
<span class="fc" id="L83"> super("Server returned HTTP response code: " + responseCode + ", message: '" + responseMessage + "'"</span>
|
|
+ " for URL: " + url, cause);
|
|
<span class="fc" id="L85"> this.responseCode = responseCode;</span>
|
|
<span class="fc" id="L86"> this.responseMessage = responseMessage;</span>
|
|
<span class="fc" id="L87"> this.url = url;</span>
|
|
<span class="fc" id="L88"> }</span>
|
|
|
|
/**
|
|
* Instantiates a new Http exception.
|
|
*
|
|
* @param responseCode
|
|
* Http response code. {@code -1} if no code can be discerned.
|
|
* @param responseMessage
|
|
* Http response message
|
|
* @param url
|
|
* The url that was invoked
|
|
* @param cause
|
|
* The cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
|
|
* permitted, and indicates that the cause is nonexistent or unknown.)
|
|
* @see HttpURLConnection#getResponseCode() HttpURLConnection#getResponseCode()
|
|
* @see HttpURLConnection#getResponseMessage() HttpURLConnection#getResponseMessage()
|
|
*/
|
|
public HttpException(int responseCode, String responseMessage, @CheckForNull URL url, Throwable cause) {
|
|
<span class="nc bnc" id="L106" title="All 2 branches missed."> this(responseCode, responseMessage, url == null ? null : url.toString(), cause);</span>
|
|
<span class="nc" id="L107"> }</span>
|
|
|
|
/**
|
|
* Http response code of the request that cause the exception
|
|
*
|
|
* @return {@code -1} if no code can be discerned.
|
|
*/
|
|
public int getResponseCode() {
|
|
<span class="fc" id="L115"> return responseCode;</span>
|
|
}
|
|
|
|
/**
|
|
* Http response message of the request that cause the exception
|
|
*
|
|
* @return {@code null} if no response message can be discerned.
|
|
*/
|
|
public String getResponseMessage() {
|
|
<span class="fc" id="L124"> return responseMessage;</span>
|
|
}
|
|
|
|
/**
|
|
* The http URL that caused the exception
|
|
*
|
|
* @return url url
|
|
*/
|
|
public String getUrl() {
|
|
<span class="fc" id="L133"> return url;</span>
|
|
}
|
|
}
|
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html> |