1.9.5
[gae.git] / java / src / main / com / google / appengine / tools / admin / HttpIoException.java
blob69b76f40000921c1d2adfc4105e5deb40b537fee
1 // Copyright 2011 Google Inc. All Rights Reserved.
3 package com.google.appengine.tools.admin;
5 /**
6 * A subclass of IOException that also carries the HTTP status code that
7 * generated the exception.
11 class HttpIoException extends RemoteIOException {
12 /**
13 * Constructs an HttpIoException (a subclass of IOException that carries
14 * the HTTP status code).
16 * @param responseCode The HTTP response code.
18 HttpIoException(int responseCode) {
19 super(null, null);
20 this.responseCode = responseCode;
23 /**
24 * Constructs an HttpIoException (a subclass of IOException that carries
25 * the HTTP status code).
27 * @param message The exception's detail message.
28 * @param responseCode The HTTP response code.
30 HttpIoException(String message, int responseCode) {
31 super(message, null);
32 this.responseCode = responseCode;
35 /**
36 * Constructs an HttpIoException (a subclass of IOException that carries
37 * the HTTP status code).
39 * @param message The exception's detail message.
40 * @param responseCode The HTTP response code.
41 * @param cause Another exception that caused this one, or null if none.
43 HttpIoException(String message, int responseCode, Throwable cause) {
44 super(message, cause);
45 this.responseCode = responseCode;
48 /**
49 * Returns The HTTP response code.
51 int getResponseCode() {
52 return responseCode;
55 /**
56 * Returns true if this HTTP status should be counted against the SLA. Currently, we consider
57 * that if the status is in the 500 range it is a server and should count against the SLA, but
58 * otherwise it is likely to be a problem with the user's environment and should not.
60 boolean isSlaError() {
61 return responseCode >= 500 && responseCode < 600;
64 private int responseCode;