diff options
Diffstat (limited to 'src/com/google/wireless/gdata/client/HttpException.java')
-rw-r--r-- | src/com/google/wireless/gdata/client/HttpException.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/com/google/wireless/gdata/client/HttpException.java b/src/com/google/wireless/gdata/client/HttpException.java new file mode 100644 index 0000000..48f1033 --- /dev/null +++ b/src/com/google/wireless/gdata/client/HttpException.java @@ -0,0 +1,58 @@ +// Copyright 2007 The Android Open Source Project + +package com.google.wireless.gdata.client; + +import java.io.InputStream; + +/** + * A class representing exceptional (i.e., non 200) responses from an HTTP + * Server. + */ +public class HttpException extends Exception { + + public static final int SC_BAD_REQUEST = 400; + + public static final int SC_UNAUTHORIZED = 401; + + public static final int SC_FORBIDDEN = 403; + + public static final int SC_NOT_FOUND = 404; + + public static final int SC_CONFLICT = 409; + + public static final int SC_GONE = 410; + + public static final int SC_INTERNAL_SERVER_ERROR = 500; + + private final int statusCode; + + private final InputStream responseStream; + + /** + * Creates an HttpException with the given message, statusCode and + * responseStream. + */ + //TODO: also record response headers? + public HttpException(String message, int statusCode, + InputStream responseStream) { + super(message); + this.statusCode = statusCode; + this.responseStream = responseStream; + } + + /** + * Gets the status code associated with this exception. + * @return the status code returned by the server, typically one of the SC_* + * constants. + */ + public int getStatusCode() { + return statusCode; + } + + /** + * @return the error response stream from the server. + */ + public InputStream getResponseStream() { + return responseStream; + } +} |