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 */
21public final class Failure {
22  private final Request request;
23  private final Throwable exception;
24
25  private Failure(Builder builder) {
26    this.request = builder.request;
27    this.exception = builder.exception;
28  }
29
30  public Request request() {
31    return request;
32  }
33
34  public Throwable exception() {
35    return exception;
36  }
37
38  public static class Builder {
39    private Request request;
40    private Throwable exception;
41
42    public Builder request(Request request) {
43      this.request = request;
44      return this;
45    }
46
47    public Builder exception(Throwable exception) {
48      this.exception = exception;
49      return this;
50    }
51
52    public Failure build() {
53      return new Failure(this);
54    }
55  }
56}
57