public static final void checkErrorResponse(boolean debug, RestCallException e, int status, String...contains) throws AssertionFailedError { String r = e.getResponseMessage(); if (debug) { System.err.println(r); // NOT DEBUG e.printStackTrace(); } if (status != e.getResponseCode()) { dumpResponse(r, "Response status code was not correct. Expected: ''{0}''. Actual: ''{1}''", status, e.getResponseCode()); throw new AssertionFailedError(format("Response status code was not correct. Expected: ''{0}''. Actual: ''{1}''", status, e.getResponseCode())); } for (String s : contains) { if (r == null || ! r.contains(s)) { if (! debug) dumpResponse(r, "Response did not have the following expected text: ''{0}''", s); throw new AssertionFailedError(format("Response did not have the following expected text: ''{0}''", s)); } } } }