Usages of

com.google.api.server.spi.ServiceException.getMessage()
/** * Writes an error in the expected form for JSON-REST: * * { * "error": { * "errors: [ * { * "domain: "global", * "reason": "backendError", * "message: "..." * } * ], * "code": 503, * "message": "..." * } * } */ @Override public void writeError(ServiceException e) throws IOException { ErrorMap errorMap = new ErrorMap(enableExceptionCompatibility); int code = errorMap.getHttpStatus(e.getStatusCode()); String reason = !Strings.isNullOrEmpty(e.getReason()) ? e.getReason() : errorMap.getReason(e.getStatusCode()); String domain = !Strings.isNullOrEmpty(e.getDomain()) ? e.getDomain() : errorMap.getDomain(e.getStatusCode()); write(code, e.getHeaders(), writeValueAsString(createError(code, reason, domain, e.getMessage()))); }
public void close(HttpServletResponse response, ServiceException e) throws IOException { response.setStatus(e.getStatusCode()); response.setContentType("text/plain"); PrintWriter writer = response.getWriter(); writer.println(e.getMessage()); writer.flush(); writer.close(); }
@Override public void writeError(ServiceException e) throws IOException { assertThat(e.getStatusCode()).isEqualTo(expectedStatus); if (checkMessage) { assertThat(innerExceptionMessage ? e.getCause().getMessage() : e.getMessage()) .isEqualTo(expectedMessage); } }
@Override public void writeError(ServiceException e) throws IOException { Map<String, String> errors = new HashMap<>(); errors.put(Constant.ERROR_MESSAGE, e.getMessage()); write(e.getStatusCode(), e.getHeaders(), writeValueAsString(errors)); }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes