RestResponseResultWriter extends ServletResponseResultWriter { @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(), createError(code, reason, domain, e.getMessage())); } RestResponseResultWriter(
      HttpServletResponse servletResponse, ApiSerializationConfig serializationConfig,
      boolean prettyPrint, boolean addContentLength, boolean enableExceptionCompatibility); @Override void writeError(ServiceException e);  }
@Test public void writeError_CustomReasonAndDomain() throws Exception { writeError(false, null, "badRequest", null, "global"); writeError(true, null, "badRequest", null, "global"); writeError(false, "", "badRequest", "", "global"); writeError(true, "", "badRequest", "", "global"); writeError(false, "customReason", "customReason", "customDomain", "customDomain"); writeError(true, "customReason", "customReason", "customDomain", "customDomain"); }