code: public Response createErrorResponse(String req, Map<String,String> metaInfo, ServiceException ex) {
          Request request = new Request(0L);
          request.setContent(req);
  
          Response response = new Response();
          String contentType = metaInfo.get(Listener.METAINFO_CONTENT_TYPE);
          if (contentType == null && req != null && !req.isEmpty())
              contentType = req.trim().startsWith("{") ? Listener.CONTENT_TYPE_JSON : Listener.CONTENT_TYPE_XML;
          if (contentType == null)
              contentType = Listener.CONTENT_TYPE_XML; // compatibility
  
          metaInfo.put(Listener.METAINFO_HTTP_STATUS_CODE, String.valueOf(ex.getCode()));
  
          StatusMessage statusMsg = new StatusMessage();
          statusMsg.setCode(ex.getCode());
          statusMsg.setMessage(ex.getMessage());
          response.setStatusCode(statusMsg.getCode());
          response.setStatusMessage(statusMsg.getMessage());
          response.setPath(ServicePaths.getInboundResponsePath(metaInfo));
          if (contentType.equals(Listener.CONTENT_TYPE_JSON)) {
              response.setContent(statusMsg.getJsonString());
          }
          else {
              response.setContent(statusMsg.getXml());
          }
          return response;
      }
docs: Create a default error message.  To customized this response use a ServiceMonitor.