| 67 | |
| 68 | // Detects of any exceptions have occured and throws the appropriate exceptions. |
| 69 | protected void detectError(HTTPClient client) throws ResponseException { |
| 70 | ResponseException exception = null; |
| 71 | if (statusCode >= 500) { |
| 72 | exception = new ServerException(this); |
| 73 | } else if (statusCode == 404) { |
| 74 | exception = new NotFoundException(this); |
| 75 | } else if (statusCode == 401) { |
| 76 | exception = new AuthenticationException(this); |
| 77 | } else if (statusCode >= 400) { |
| 78 | exception = new ClientException(this); |
| 79 | } else if (statusCode == 204) { |
| 80 | return; |
| 81 | } else if (!parsed) { |
| 82 | exception = new ParserException(this); |
| 83 | } |
| 84 | |
| 85 | if (exception != null) { |
| 86 | exception.log(client.getConfiguration()); |
| 87 | throw exception; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | // Tries to parse the status code. Catches any exceptions and defaults to |
| 92 | // status 0 if an error occurred. |