Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: components/cronet/android/api/src/org/chromium/net/UrlRequestException.java

Issue 2569863002: [Cronet] Remove deprecated UrlRequestException. (Closed)
Patch Set: Update api.txt Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.net;
6
7 import java.io.IOException;
8
9 /**
10 * @deprecated Use {@link CronetException} instead.
11 * {@hide This class will be removed after complete transition to CronetExceptio n}.
12 */
13 @Deprecated
14 public class UrlRequestException extends IOException {
15 /**
16 * Error code indicating this class wraps an exception thrown by {@link UrlR equest.Callback} or
17 * {@link UploadDataProvider}. Wrapped exception can be retrieved using
18 * {@link IOException#getCause}.
19 */
20 public static final int ERROR_LISTENER_EXCEPTION_THROWN = 0;
21 /**
22 * Error code indicating the host being sent the request could not be resolv ed to an IP address.
23 */
24 public static final int ERROR_HOSTNAME_NOT_RESOLVED = 1;
25 /**
26 * Error code indicating the device was not connected to any network.
27 */
28 public static final int ERROR_INTERNET_DISCONNECTED = 2;
29 /**
30 * Error code indicating that as the request was processed the network confi guration changed.
31 */
32 public static final int ERROR_NETWORK_CHANGED = 3;
33 /**
34 * Error code indicating a timeout expired. Timeouts expiring while attempti ng to connect will
35 * be reported as the more specific {@link #ERROR_CONNECTION_TIMED_OUT}.
36 */
37 public static final int ERROR_TIMED_OUT = 4;
38 /**
39 * Error code indicating the connection was closed unexpectedly.
40 */
41 public static final int ERROR_CONNECTION_CLOSED = 5;
42 /**
43 * Error code indicating the connection attempt timed out.
44 */
45 public static final int ERROR_CONNECTION_TIMED_OUT = 6;
46 /**
47 * Error code indicating the connection attempt was refused.
48 */
49 public static final int ERROR_CONNECTION_REFUSED = 7;
50 /**
51 * Error code indicating the connection was unexpectedly reset.
52 */
53 public static final int ERROR_CONNECTION_RESET = 8;
54 /**
55 * Error code indicating the IP address being contacted is unreachable, mean ing there is no
56 * route to the specified host or network.
57 */
58 public static final int ERROR_ADDRESS_UNREACHABLE = 9;
59 /**
60 * Error code indicating an error related to the <a href="https://www.chromi um.org/quic">
61 * QUIC</a> protocol. When {@link #getErrorCode} returns this code, this exc eption can be cast
62 * to {@link QuicException} for more information.
63 */
64 public static final int ERROR_QUIC_PROTOCOL_FAILED = 10;
65 /**
66 * Error code indicating another type of error was encountered.
67 * {@link #getCronetInternalErrorCode} can be consulted to get a more specif ic cause.
68 */
69 public static final int ERROR_OTHER = 11;
70
71 // Error code, one of ERROR_*
72 private final int mErrorCode;
73 // Cronet internal error code.
74 private final int mCronetInternalErrorCode;
75
76 public UrlRequestException(CronetException error) {
77 super(error.getMessage(), error.getCause());
78 if (error instanceof NetworkException) {
79 mErrorCode = ((NetworkException) error).getErrorCode();
80 mCronetInternalErrorCode = ((NetworkException) error).getCronetInter nalErrorCode();
81 } else {
82 mErrorCode = 0;
83 mCronetInternalErrorCode = ERROR_LISTENER_EXCEPTION_THROWN;
84 }
85 }
86
87 /**
88 * Returns error code, one of {@link #ERROR_LISTENER_EXCEPTION_THROWN ERROR_ *}.
89 *
90 * @return error code, one of {@link #ERROR_LISTENER_EXCEPTION_THROWN ERROR_ *}.
91 */
92 public int getErrorCode() {
93 return mErrorCode;
94 }
95
96 /**
97 * Returns a Cronet internal error code. This may provide more specific erro r
98 * diagnosis than {@link #getErrorCode}, but the constant values are not exp osed to Java and
99 * may change over time. See
100 * <a href=https://chromium.googlesource.com/chromium/src/+/master/net/base/ net_error_list.h>
101 * here</a> for the lastest list of values.
102 *
103 * @return Cronet internal error code.
104 */
105 public int getCronetInternalErrorCode() {
106 return mCronetInternalErrorCode;
107 }
108
109 /**
110 * Returns {@code true} if retrying this request right away might succeed, { @code false}
111 * otherwise. For example returns {@code true} when {@link #getErrorCode} re turns
112 * {@link #ERROR_NETWORK_CHANGED} because trying the request might succeed u sing the new
113 * network configuration, but {@code false} when {@code getErrorCode()} retu rns
114 * {@link #ERROR_INTERNET_DISCONNECTED} because retrying the request right a way will
115 * encounter the same failure (instead retrying should be delayed until devi ce regains
116 * network connectivity). Returns {@code false} when {@code getErrorCode()} returns
117 * {@link #ERROR_LISTENER_EXCEPTION_THROWN}.
118 *
119 * @return {@code true} if retrying this request right away might succeed, { @code false}
120 * otherwise.
121 */
122 public boolean immediatelyRetryable() {
123 switch (mErrorCode) {
124 case ERROR_LISTENER_EXCEPTION_THROWN:
125 case ERROR_HOSTNAME_NOT_RESOLVED:
126 case ERROR_INTERNET_DISCONNECTED:
127 case ERROR_CONNECTION_REFUSED:
128 case ERROR_ADDRESS_UNREACHABLE:
129 case ERROR_OTHER:
130 default:
131 return false;
132 case ERROR_NETWORK_CHANGED:
133 case ERROR_TIMED_OUT:
134 case ERROR_CONNECTION_CLOSED:
135 case ERROR_CONNECTION_TIMED_OUT:
136 case ERROR_CONNECTION_RESET:
137 return true;
138 }
139 }
140 }
OLDNEW
« no previous file with comments | « components/cronet/android/api/src/org/chromium/net/UrlRequest.java ('k') | components/cronet/android/api_version.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698