/** * Checks if the response contains any error message. */ protected final WebResponse checkError(WebResponse resp) throws SAXException, ProcessingException, IOException { if(resp.getResponseCode()!=200) throw new ProcessingException("request failed "+resp.getResponseMessage()); Document dom = Util.getDom4j(resp); org.dom4j.Node errorNode = dom.selectSingleNode("//DIV[@class='errormessage']"); if(errorNode!=null) { // this happens for example when you request "http://nosuchproject.dev.java.net/" throw new ProcessingException(errorNode.getStringValue().trim()); } return resp; }
/** * Examines the headers in the response and throws an exception if appropriate. * @parm response - the response to validate **/ private void validateHeaders( WebResponse response ) throws HttpException { if (!getExceptionsThrownOnErrorStatus()) return; // see feature request [ 914314 ] Add HttpException.getResponse for better reporting // for possible improvements here if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) { throw new HttpInternalErrorException( response.getURL() ); } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new HttpNotFoundException( response.getResponseMessage(), response.getURL() ); } else if (response.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { throw new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() ); } }
/** * Examines the headers in the response and throws an exception if appropriate. * @parm response - the response to validate **/ private void validateHeaders( WebResponse response ) throws HttpException { if (!getExceptionsThrownOnErrorStatus()) return; // see feature request [ 914314 ] Add HttpException.getResponse for better reporting // for possible improvements here if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) { throw new HttpInternalErrorException( response.getURL() ); } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new HttpNotFoundException( response.getResponseMessage(), response.getURL() ); } else if (response.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { throw new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() ); } }
/** * Examines the headers in the response and throws an exception if appropriate. * @parm response - the response to validate **/ private void validateHeaders( WebResponse response ) throws HttpException { if (!getExceptionsThrownOnErrorStatus()) return; // see feature request [ 914314 ] Add HttpException.getResponse for better reporting // for possible improvements here if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) { throw new HttpInternalErrorException( response.getURL() ); } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new HttpNotFoundException( response.getResponseMessage(), response.getURL() ); } else if (response.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { throw new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() ); } }