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

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: Rewrite for design changes as discussed Created 4 years, 5 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:
11 * <ul> 11 * <ul>
12 * <li>{@link UrlRequest.Callback} or {@link UploadDataProvider} method throws a n exception. In this 12 * <li>{@link UrlRequest.Callback} or {@link UploadDataProvider} method throws a n exception. In this
13 * case {@link IOException#getCause getCause()} can be used to find the thro wn exception. 13 * case {@link IOException#getCause getCause()} can be used to find the thro wn exception.
14 * {@link #getErrorCode} will return {@link #ERROR_LISTENER_EXCEPTION_THROWN }. 14 * {@link #getErrorCode} will return {@link #ERROR_LISTENER_EXCEPTION_THROWN }.
15 * <li>Cronet fails to process a network request. In this case 15 * <li>Cronet fails to process a network request. In this case
16 * {@link #getErrorCode} and {@link #getCronetInternalErrorCode} can be used to get more 16 * {@link #getErrorCode} and {@link #getCronetInternalErrorCode} can be used to get more
17 * information about the specific type of failure. 17 * information about the specific type of failure. If {@link #getCronetInter nalErrorCode}
18 * returns {@link #QUIC_PROTOCOL_ERROR}, this exception can be cast to a {@l ink QuicException}
19 * which can provide further details.
18 * </ul> 20 * </ul>
19 */ 21 */
20 public class UrlRequestException extends IOException { 22 public class UrlRequestException extends IOException {
21 /** 23 /**
22 * Error code indicating this class wraps an exception thrown by {@link UrlR equest.Callback} or 24 * Error code indicating this class wraps an exception thrown by {@link UrlR equest.Callback} or
23 * {@link UploadDataProvider}. Wrapped exception can be retrieved using 25 * {@link UploadDataProvider}. Wrapped exception can be retrieved using
24 * {@link IOException#getCause}. 26 * {@link IOException#getCause}.
25 */ 27 */
26 public static final int ERROR_LISTENER_EXCEPTION_THROWN = 28 public static final int ERROR_LISTENER_EXCEPTION_THROWN =
27 UrlRequestError.LISTENER_EXCEPTION_THROWN; 29 UrlRequestError.LISTENER_EXCEPTION_THROWN;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 * Error code indicating the IP address being contacted is unreachable, mean ing there is no 64 * Error code indicating the IP address being contacted is unreachable, mean ing there is no
63 * route to the specified host or network. 65 * route to the specified host or network.
64 */ 66 */
65 public static final int ERROR_ADDRESS_UNREACHABLE = UrlRequestError.ADDRESS_ UNREACHABLE; 67 public static final int ERROR_ADDRESS_UNREACHABLE = UrlRequestError.ADDRESS_ UNREACHABLE;
66 /** 68 /**
67 * Error code indicating another type of error was encountered. 69 * Error code indicating another type of error was encountered.
68 * {@link #getCronetInternalErrorCode} can be consulted to get a more specif ic cause. 70 * {@link #getCronetInternalErrorCode} can be consulted to get a more specif ic cause.
69 */ 71 */
70 public static final int ERROR_OTHER = UrlRequestError.OTHER; 72 public static final int ERROR_OTHER = UrlRequestError.OTHER;
71 73
74 /**
75 * Error code indicating an error during a QUIC connection. Unlike the ERROR _* constants, this
76 * will appear as a return value from {@link #getCronetInternalErrorCode}, n ot
77 * {@link #getErrorCode}.
78 */
79 public static final int QUIC_PROTOCOL_ERROR = -356;
xunjieli 2016/06/30 14:13:43 We can just reuse NetError.ERR_QUIC_PROTOCOL_ERROR
mgersh 2016/06/30 16:50:53 Done.
80
72 // Error code, one of ERROR_* 81 // Error code, one of ERROR_*
73 private final int mErrorCode; 82 private final int mErrorCode;
74 // Cronet internal error code. 83 // Cronet internal error code.
75 private final int mCronetInternalErrorCode; 84 private final int mCronetInternalErrorCode;
76 85
77 /** 86 /**
78 * Constructs an exception with a specific error. 87 * Constructs an exception with a specific error.
79 * 88 *
80 * @param message explanation of failure. 89 * @param message explanation of failure.
81 * @param errorCode error code, one of {@link #ERROR_LISTENER_EXCEPTION_THRO WN ERROR_*}. 90 * @param errorCode error code, one of {@link #ERROR_LISTENER_EXCEPTION_THRO WN ERROR_*}.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return false; 157 return false;
149 case ERROR_NETWORK_CHANGED: 158 case ERROR_NETWORK_CHANGED:
150 case ERROR_TIMED_OUT: 159 case ERROR_TIMED_OUT:
151 case ERROR_CONNECTION_CLOSED: 160 case ERROR_CONNECTION_CLOSED:
152 case ERROR_CONNECTION_TIMED_OUT: 161 case ERROR_CONNECTION_TIMED_OUT:
153 case ERROR_CONNECTION_RESET: 162 case ERROR_CONNECTION_RESET:
154 return true; 163 return true;
155 } 164 }
156 } 165 }
157 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698