// Path: library/src/main/java/org/mariotaku/restfu/ExceptionFactory.java
// public interface ExceptionFactory<E extends Exception> {
// 
//     @NotNull
//     E newException(@Nullable final Throwable cause, @Nullable final HttpRequest request,
//             @Nullable final HttpResponse response);
// 
// }
// 
// Path: library/src/main/java/org/mariotaku/restfu/http/HttpRequest.java
// public final class HttpRequest {
// 
//     private final String method;
//     private final String url;
//     private final MultiValueMap<String> headers;
//     private final Body body;
//     private final Object tag;
// 
//     public String getMethod() {
//         return method;
//     }
// 
//     public String getUrl() {
//         return url;
//     }
// 
//     public MultiValueMap<String> getHeaders() {
//         return headers;
//     }
// 
//     public Body getBody() {
//         return body;
//     }
// 
//     public Object getTag() {
//         return tag;
//     }
// 
//     @Override
//     public String toString() {
//         StringBuilder sb = new StringBuilder(method);
//         sb.append(' ');
//         sb.append(url);
//         if (body != null) {
//             sb.append(" (has body)");
//         }
//         return sb.toString();
//     }
// 
//     public HttpRequest(String method, String url, MultiValueMap<String> headers, Body body, Object tag) {
//         this.method = method;
//         this.url = url;
//         this.headers = headers;
//         this.body = body;
//         this.tag = tag;
//     }
// 
//     public static final class Builder {
//         private String method;
//         private String url;
//         private MultiValueMap<String> headers;
//         private Body body;
//         private Object tag;
// 
//         public Builder() {
//         }
// 
//         public Builder method(String method) {
//             this.method = method;
//             return this;
//         }
// 
//         public Builder url(String url) {
//             this.url = url;
//             return this;
//         }
// 
//         public Builder headers(MultiValueMap<String> headers) {
//             this.headers = headers;
//             return this;
//         }
// 
//         public Builder body(Body body) {
//             this.body = body;
//             return this;
//         }
// 
//         public Builder tag(Object tag) {
//             this.tag = tag;
//             return this;
//         }
// 
//         public HttpRequest build() {
//             return new HttpRequest(method, url, headers, body, tag);
//         }
//     }
// 
// 
//     public static class DefaultFactory<E extends Exception> implements Factory<E> {
// 
//         @NotNull
//         @Override
//         public HttpRequest create(Endpoint endpoint, RestRequest requestInfo,
//                 Authorization authorization, RestConverter.Factory<E> converterFactory) throws E,
//                 RestConverter.ConvertException, IOException {
//             final String url = Endpoint.constructUrl(endpoint.getUrl(), requestInfo);
//             MultiValueMap<String> headers = requestInfo.getHeaders();
//             if (headers == null) {
//                 headers = new MultiValueMap<>();
//             }
//             if (authorization != null && authorization.hasAuthorization()) {
//                 headers.add("Authorization", authorization.getHeader(endpoint, requestInfo));
//             }
//             return new HttpRequest(requestInfo.getMethod(), url, headers, requestInfo.getBody(converterFactory), null);
//         }
//     }
// 
//     /**
//      * Created by mariotaku on 15/5/25.
//      */
//     public interface Factory<E extends Exception> {
//         @NotNull
//         HttpRequest create(Endpoint endpoint, RestRequest info, Authorization authorization,
//                 RestConverter.Factory<E> converterFactory) throws E, RestConverter.ConvertException, IOException;
//     }
// }
// 
// Path: library/src/main/java/org/mariotaku/restfu/http/HttpResponse.java
// public abstract class HttpResponse implements Closeable {
//     public abstract int getStatus();
// 
//     public abstract MultiValueMap<String> getHeaders();
// 
//     public abstract Body getBody();
// 
//     public String getHeader(String name) {
//         if (name == null) throw new NullPointerException();
//         return getHeaders().getFirst(name);
//     }
// 
//     public List<String> getHeaders(String name) {
//         if (name == null) throw new NullPointerException();
//         return getHeaders().get(name);
//     }
// 
//     /**
//      * Returns true if the code is in [200..300), which means the request was
//      * successfully received, understood, and accepted.
//      *
//      * @return True if HTTP response is successful response
//      */
//     public boolean isSuccessful() {
//         final int status = getStatus();
//         return status >= 200 && status < 300;
//     }
// 
//     @Override
//     public String toString() {
//         return "HTTP " + getStatus();
//     }
// }


import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.mariotaku.restfu.ExceptionFactory;
import org.mariotaku.restfu.http.HttpRequest;
import org.mariotaku.restfu.http.HttpResponse;

/**
 * Created by mariotaku on 16/1/17.
 */
public class GithubExceptionFactory implements ExceptionFactory<GithubException> {
    @Override
    @NotNull
// Path: library/src/main/java/org/mariotaku/restfu/ExceptionFactory.java
// public interface ExceptionFactory<E extends Exception> {
// 
//     @NotNull
//     E newException(@Nullable final Throwable cause, @Nullable final HttpRequest request,
//             @Nullable final HttpResponse response);
// 
// }
// 
// Path: library/src/main/java/org/mariotaku/restfu/http/HttpRequest.java
// public final class HttpRequest {
// 
//     private final String method;
//     private final String url;
//     private final MultiValueMap<String> headers;
//     private final Body body;
//     private final Object tag;
// 
//     public String getMethod() {
//         return method;
//     }
// 
//     public String getUrl() {
//         return url;
//     }
// 
//     public MultiValueMap<String> getHeaders() {
//         return headers;
//     }
// 
//     public Body getBody() {
//         return body;
//     }
// 
//     public Object getTag() {
//         return tag;
//     }
// 
//     @Override
//     public String toString() {
//         StringBuilder sb = new StringBuilder(method);
//         sb.append(' ');
//         sb.append(url);
//         if (body != null) {
//             sb.append(" (has body)");
//         }
//         return sb.toString();
//     }
// 
//     public HttpRequest(String method, String url, MultiValueMap<String> headers, Body body, Object tag) {
//         this.method = method;
//         this.url = url;
//         this.headers = headers;
//         this.body = body;
//         this.tag = tag;
//     }
// 
//     public static final class Builder {
//         private String method;
//         private String url;
//         private MultiValueMap<String> headers;
//         private Body body;
//         private Object tag;
// 
//         public Builder() {
//         }
// 
//         public Builder method(String method) {
//             this.method = method;
//             return this;
//         }
// 
//         public Builder url(String url) {
//             this.url = url;
//             return this;
//         }
// 
//         public Builder headers(MultiValueMap<String> headers) {
//             this.headers = headers;
//             return this;
//         }
// 
//         public Builder body(Body body) {
//             this.body = body;
//             return this;
//         }
// 
//         public Builder tag(Object tag) {
//             this.tag = tag;
//             return this;
//         }
// 
//         public HttpRequest build() {
//             return new HttpRequest(method, url, headers, body, tag);
//         }
//     }
// 
// 
//     public static class DefaultFactory<E extends Exception> implements Factory<E> {
// 
//         @NotNull
//         @Override
//         public HttpRequest create(Endpoint endpoint, RestRequest requestInfo,
//                 Authorization authorization, RestConverter.Factory<E> converterFactory) throws E,
//                 RestConverter.ConvertException, IOException {
//             final String url = Endpoint.constructUrl(endpoint.getUrl(), requestInfo);
//             MultiValueMap<String> headers = requestInfo.getHeaders();
//             if (headers == null) {
//                 headers = new MultiValueMap<>();
//             }
//             if (authorization != null && authorization.hasAuthorization()) {
//                 headers.add("Authorization", authorization.getHeader(endpoint, requestInfo));
//             }
//             return new HttpRequest(requestInfo.getMethod(), url, headers, requestInfo.getBody(converterFactory), null);
//         }
//     }
// 
//     /**
//      * Created by mariotaku on 15/5/25.
//      */
//     public interface Factory<E extends Exception> {
//         @NotNull
//         HttpRequest create(Endpoint endpoint, RestRequest info, Authorization authorization,
//                 RestConverter.Factory<E> converterFactory) throws E, RestConverter.ConvertException, IOException;
//     }
// }
// 
// Path: library/src/main/java/org/mariotaku/restfu/http/HttpResponse.java
// public abstract class HttpResponse implements Closeable {
//     public abstract int getStatus();
// 
//     public abstract MultiValueMap<String> getHeaders();
// 
//     public abstract Body getBody();
// 
//     public String getHeader(String name) {
//         if (name == null) throw new NullPointerException();
//         return getHeaders().getFirst(name);
//     }
// 
//     public List<String> getHeaders(String name) {
//         if (name == null) throw new NullPointerException();
//         return getHeaders().get(name);
//     }
// 
//     /**
//      * Returns true if the code is in [200..300), which means the request was
//      * successfully received, understood, and accepted.
//      *
//      * @return True if HTTP response is successful response
//      */
//     public boolean isSuccessful() {
//         final int status = getStatus();
//         return status >= 200 && status < 300;
//     }
// 
//     @Override
//     public String toString() {
//         return "HTTP " + getStatus();
//     }
// }


// Path: sample/src/main/java/GithubExceptionFactory.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.mariotaku.restfu.ExceptionFactory;
import org.mariotaku.restfu.http.HttpRequest;
import org.mariotaku.restfu.http.HttpResponse;


/**
 * Created by mariotaku on 16/1/17.
 */
public class GithubExceptionFactory implements ExceptionFactory<GithubException> {
    @Override
    @NotNull
    public GithubException newException(@Nullable Throwable cause, @Nullable HttpRequest request, @Nullable HttpResponse response) {