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

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

Issue 2069303002: Add new Cronet exception class for QUIC errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import java.io.IOException; 7 import java.io.IOException;
8 8
9 /** 9 /**
10 * Exception passed to {@link UrlRequest.Callback#onFailed UrlRequest.Callback.o nFailed()} when: 10 * Exception passed to {@link UrlRequest.Callback#onFailed UrlRequest.Callback.o nFailed()} when:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 /** 66 /**
67 * Error code indicating another type of error was encountered. 67 * Error code indicating another type of error was encountered.
68 * {@link #getCronetInternalErrorCode} can be consulted to get a more specif ic cause. 68 * {@link #getCronetInternalErrorCode} can be consulted to get a more specif ic cause.
69 */ 69 */
70 public static final int ERROR_OTHER = UrlRequestError.OTHER; 70 public static final int ERROR_OTHER = UrlRequestError.OTHER;
71 71
72 // Error code, one of ERROR_* 72 // Error code, one of ERROR_*
73 private final int mErrorCode; 73 private final int mErrorCode;
74 // Cronet internal error code. 74 // Cronet internal error code.
75 private final int mCronetInternalErrorCode; 75 private final int mCronetInternalErrorCode;
76 // Cronet internal error details.
77 private final int mCronetInternalErrorDetails;
76 78
77 /** 79 /**
78 * Constructs an exception with a specific error. 80 * Constructs an exception with a specific error.
79 * 81 *
80 * @param message explanation of failure. 82 * @param message explanation of failure.
81 * @param errorCode error code, one of {@link #ERROR_LISTENER_EXCEPTION_THRO WN ERROR_*}. 83 * @param errorCode error code, one of {@link #ERROR_LISTENER_EXCEPTION_THRO WN ERROR_*}.
82 * @param cronetInternalErrorCode Cronet internal error code, one of 84 * @param cronetInternalErrorCode Cronet internal error code, one of
83 * <a href=https://chromium.googlesource.com/chromium/src/+/master/net/base/ net_error_list.h> 85 * <a href=https://chromium.googlesource.com/chromium/src/+/master/net/base/ net_error_list.h>
84 * these</a>. 86 * these</a>.
87 * @param cronetInternalErrorDetails Cronet internal error code details when the error code
88 * is QUIC_PROTOCOL_ERROR, from
89 * <a href=https://chromium.googlesource.com/chromium/src/+/master/net/quic/ quic_protocol.h#503>
90 * this file</a>.
85 */ 91 */
86 public UrlRequestException(String message, int errorCode, int cronetInternal ErrorCode) { 92 public UrlRequestException(String message, int errorCode, int cronetInternal ErrorCode,
93 int cronetInternalErrorDetails) {
87 super(message, null); 94 super(message, null);
88 mErrorCode = errorCode; 95 mErrorCode = errorCode;
89 mCronetInternalErrorCode = cronetInternalErrorCode; 96 mCronetInternalErrorCode = cronetInternalErrorCode;
97 mCronetInternalErrorDetails = cronetInternalErrorDetails;
90 } 98 }
91 99
92 /** 100 /**
93 * Constructs an exception that wraps {@code cause} thrown by a {@link UrlRe quest.Callback}. 101 * Constructs an exception that wraps {@code cause} thrown by a {@link UrlRe quest.Callback}.
94 * 102 *
95 * @param message explanation of failure. 103 * @param message explanation of failure.
96 * @param cause exception thrown by {@link UrlRequest.Callback} that's being wrapped. 104 * @param cause exception thrown by {@link UrlRequest.Callback} that's being wrapped.
97 */ 105 */
98 public UrlRequestException(String message, Throwable cause) { 106 public UrlRequestException(String message, Throwable cause) {
99 super(message, cause); 107 super(message, cause);
100 mErrorCode = ERROR_LISTENER_EXCEPTION_THROWN; 108 mErrorCode = ERROR_LISTENER_EXCEPTION_THROWN;
101 mCronetInternalErrorCode = 0; 109 mCronetInternalErrorCode = 0;
110 mCronetInternalErrorDetails = 0;
102 } 111 }
103 112
104 /** 113 /**
105 * Returns error code, one of {@link #ERROR_LISTENER_EXCEPTION_THROWN ERROR_ *}. 114 * Returns error code, one of {@link #ERROR_LISTENER_EXCEPTION_THROWN ERROR_ *}.
106 * 115 *
107 * @return error code, one of {@link #ERROR_LISTENER_EXCEPTION_THROWN ERROR_ *}. 116 * @return error code, one of {@link #ERROR_LISTENER_EXCEPTION_THROWN ERROR_ *}.
108 */ 117 */
109 public int getErrorCode() { 118 public int getErrorCode() {
110 return mErrorCode; 119 return mErrorCode;
111 } 120 }
112 121
113 /** 122 /**
114 * Returns a Cronet internal error code. This may provide more specific erro r 123 * Returns a Cronet internal error code. This may provide more specific erro r
115 * diagnosis than {@link #getErrorCode}, but the constant values are not exp osed to Java and 124 * diagnosis than {@link #getErrorCode}, but the constant values are not exp osed to Java and
116 * may change over time. See 125 * may change over time. See
117 * <a href=https://chromium.googlesource.com/chromium/src/+/master/net/base/ net_error_list.h> 126 * <a href=https://chromium.googlesource.com/chromium/src/+/master/net/base/ net_error_list.h>
118 * here</a> for the lastest list of values. 127 * here</a> for the lastest list of values.
119 * 128 *
120 * @return Cronet internal error code. 129 * @return Cronet internal error code.
121 */ 130 */
122 public int getCronetInternalErrorCode() { 131 public int getCronetInternalErrorCode() {
123 return mCronetInternalErrorCode; 132 return mCronetInternalErrorCode;
124 } 133 }
125 134
126 /** 135 /**
136 * Returns detailed information related to the Cronet internal error code. C urrently this is a
137 * code from
138 * <a href=https://chromium.googlesource.com/chromium/src/+/master/net/quic/ quic_protocol.h>
139 * QuicErrorCode</a> and is only meaningful if the Cronet internal error cod e is
140 * QUIC_PROTOCOL_ERROR.
141 */
142 public int getCronetInternalErrorDetails() {
143 return mCronetInternalErrorDetails;
144 }
145
146 /**
127 * Returns {@code true} if retrying this request right away might succeed, { @code false} 147 * Returns {@code true} if retrying this request right away might succeed, { @code false}
128 * otherwise. For example returns {@code true} when {@link #getErrorCode} re turns 148 * otherwise. For example returns {@code true} when {@link #getErrorCode} re turns
129 * {@link #ERROR_NETWORK_CHANGED} because trying the request might succeed u sing the new 149 * {@link #ERROR_NETWORK_CHANGED} because trying the request might succeed u sing the new
130 * network configuration, but {@code false} when {@code getErrorCode()} retu rns 150 * network configuration, but {@code false} when {@code getErrorCode()} retu rns
131 * {@link #ERROR_INTERNET_DISCONNECTED} because retrying the request right a way will 151 * {@link #ERROR_INTERNET_DISCONNECTED} because retrying the request right a way will
132 * encounter the same failure (instead retrying should be delayed until devi ce regains 152 * encounter the same failure (instead retrying should be delayed until devi ce regains
133 * network connectivity). Returns {@code false} when {@code getErrorCode()} returns 153 * network connectivity). Returns {@code false} when {@code getErrorCode()} returns
134 * {@link #ERROR_LISTENER_EXCEPTION_THROWN}. 154 * {@link #ERROR_LISTENER_EXCEPTION_THROWN}.
135 * 155 *
136 * @return {@code true} if retrying this request right away might succeed, { @code false} 156 * @return {@code true} if retrying this request right away might succeed, { @code false}
(...skipping 11 matching lines...) Expand all
148 return false; 168 return false;
149 case ERROR_NETWORK_CHANGED: 169 case ERROR_NETWORK_CHANGED:
150 case ERROR_TIMED_OUT: 170 case ERROR_TIMED_OUT:
151 case ERROR_CONNECTION_CLOSED: 171 case ERROR_CONNECTION_CLOSED:
152 case ERROR_CONNECTION_TIMED_OUT: 172 case ERROR_CONNECTION_TIMED_OUT:
153 case ERROR_CONNECTION_RESET: 173 case ERROR_CONNECTION_RESET:
154 return true; 174 return true;
155 } 175 }
156 } 176 }
157 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698