1/* 2 * Copyright (C) 2013 Square, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package com.squareup.okhttp; 17 18/** 19 * A failure attempting to retrieve an HTTP response. 20 * 21 * <h3>Warning: Experimental OkHttp 2.0 API</h3> 22 * This class is in beta. APIs are subject to change! 23 */ 24public class Failure { 25 private final Request request; 26 private final Throwable exception; 27 28 private Failure(Builder builder) { 29 this.request = builder.request; 30 this.exception = builder.exception; 31 } 32 33 public Request request() { 34 return request; 35 } 36 37 public Throwable exception() { 38 return exception; 39 } 40 41 public static class Builder { 42 private Request request; 43 private Throwable exception; 44 45 public Builder request(Request request) { 46 this.request = request; 47 return this; 48 } 49 50 public Builder exception(Throwable exception) { 51 this.exception = exception; 52 return this; 53 } 54 55 public Failure build() { 56 return new Failure(this); 57 } 58 } 59} 60