通知不成功
@param errMsg 失败消息
@return 通知失败的XML消息
439773
public String notOk(String errMsg){
        Map<String, String> notifyParams = new HashMap<>();
        notifyParams.put(WepayField.RETURN_CODE, "FAIL");
        notifyParams.put(WepayField.RETURN_MSG, errMsg);
        return Maps.toXml(notifyParams);
    }
1127365
public static Document getResultSetAsXML(ResultSet rs, String tableName) throws Exception {
        return getResultSetAsXML(rs, tableName, "");
    }
938791
private String parseErrorCodeFromHeader(Map<String, String> httpHeaders) {
        String headerValue = httpHeaders.get(X_AMZN_ERROR_TYPE);
        if (headerValue != null) {
            int separator = headerValue.indexOf(':');
            if (separator != -1) {
                headerValue = headerValue.substring(0, separator);
            }
        }
        return headerValue;
    }
172628
public static String toXml(Map<String, String> params) {
		StringBuilder xml = new StringBuilder();
		xml.append("<xml>");
		for (Entry<String, String> entry : params.entrySet()) {
			String key = entry.getKey();
			String value = entry.getValue();
			// 略过空值
			if (StrKit.isBlank(value))
				continue;
			xml.append("<").append(key).append(">");
			xml.append(entry.getValue());
			xml.append("</").append(key).append(">");
		}
		xml.append("</xml>");
		return xml.toString();
	}
1165584
public String parseErrorMessage(HttpResponse httpResponse, JsonNode jsonNode) {
        // If X_AMZN_ERROR_MESSAGE is present, prefer that. Otherwise check the JSON body.
        final String headerMessage = httpResponse.getHeader(X_AMZN_ERROR_MESSAGE);
        if (headerMessage != null) {
            return headerMessage;
        }
        for (String field : errorMessageJsonLocations) {
            JsonNode value = jsonNode.get(field);
            if (value != null && value.isTextual()) {
                return value.asText();
            }
        }
        return null;
    }
653690
public static FailedRequest getFailedRequest(int httpStatus, String contentType, InputStream content) {
    FailedRequest failure = null;

    // by default XML is supported
    if ( contentType != null ) {
      MediaType mediaType = MediaType.parse(contentType);
      if ( "xml".equals(mediaType.subtype()) ) {
        FailedRequestParser xmlParser = new FailedRequestXMLParser();

        failure = xmlParser.parseFailedRequest(httpStatus, content);
      } else if ( "json".equals(mediaType.subtype()) ) {
        failure = jsonFailedRequest(httpStatus, content);
      }
    } else if (httpStatus == 404) {
      failure = new FailedRequest();
      failure.setStatusCode(httpStatus);
      failure.setMessageString("");
      failure.setStatusString("Not Found");
    }
    if ( failure == null ) {
      failure = new FailedRequest();
      failure.setStatusCode(httpStatus);
      failure.setMessageCode("UNKNOWN");
      failure.setMessageString("Server (not a REST instance?) did not respond with an expected REST Error message.");
      failure.setStatusString("UNKNOWN");
    }
    if (failure.getStatusCode() == 401) {
      failure.setMessageString("Unauthorized");
      failure.setStatusString("Failed Auth");
    }
    return failure;

  }
1149347
public StringBuilder toMsg(StringBuilder sb,  String attErrJson) throws APIException {
		return toMsg(sb,errDF.newData().in(TYPE.JSON).load(attErrJson).asObject());
	}
272430
def _extractErrorString(request):
        
        errorStr = ""

        tag = None

        # noinspection PyBroadException
        try:
            # parse XML return
            root = ET.fromstring(request.text.encode('utf-8'))
            tag = root[0][0]
        except:
            # return an empty string as we can not parse the structure
            return errorStr

        for element in tag.getiterator():
            tagName = element.tag.lower()

            if tagName.endswith("string"):
                errorStr += element.text + " "
            elif tagName.endswith("description"):
                errorStr += element.text + " "

        return errorStr
878531
public static UnitResponse createSuccess(Object data, String errMsg) {
        return createSuccess(data).setMessage(errMsg);
    }
1136896
public static MimeMessage emlToMimeMessage(@Nonnull final String eml, @Nonnull final Session session) {
		checkNonEmptyArgument(session, "session");
		checkNonEmptyArgument(eml, "eml");
		try {
			return new MimeMessage(session, new ByteArrayInputStream(eml.getBytes(UTF_8)));
		} catch (final MessagingException e) {
			throw new EmailConverterException(format(EmailConverterException.PARSE_ERROR_EML, e.getMessage()), e);
		}
	}
1194930
public static Map<String, String> convertToMap(String xml) {
		Map<String, String> map = new LinkedHashMap<String, String>();
		try {
			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

			/*
			 * 避免 XXE 攻击
			 * 
			 * @since 2.8.21
			 */
			dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
			dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
			dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
			dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
			dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
			dbf.setXIncludeAware(false);
			dbf.setExpandEntityReferences(false);

			DocumentBuilder db = dbf.newDocumentBuilder();
			StringReader sr = new StringReader(xml);
			InputSource is = new InputSource(sr);
			Document document = db.parse(is);

			Element root = document.getDocumentElement();
			if (root != null) {
				NodeList childNodes = root.getChildNodes();
				if (childNodes != null && childNodes.getLength() > 0) {
					for (int i = 0; i < childNodes.getLength(); i++) {
						Node node = childNodes.item(i);
						if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
							map.put(node.getNodeName(), node.getTextContent());
						}
					}
				}
			}
		} catch (Exception e) {
			logger.error("", e);
		}
		return map;
	}
951882
private static String serialize(IApiError err) {
		return STR.joinArgs("|", err.name(), Check.ifNull(err.param(), ""));
	}
613746
public function logError( $errMsg, $context = null )
    {
        $errMsg = $context != null ? $errMsg . ' - ' . $context : $errMsg;
        error_log( $errMsg );
    }
154160
public static Map<String, String> getServerErrorMap(HttpServletRequest request, Exception e) {
        Map<String, String> attributes = new HashMap<>(4);
        attributes.put("code", "500");
        attributes.put("message", e.getMessage());
        String queryString = request.getQueryString();
        attributes.put("url", request.getRequestURI() + (Checker.isEmpty(queryString) ? "" : "?" + queryString));
        return attributes;
    }
433562
public function format_error_message($errormsg) {
        $errors = unserialize($errormsg);
        $output = 'mnet_xmlrpc_client request returned errors:'."\n";
        foreach ($errors as $error) {
            $output .= "$error\n";
        }
        return $output;
    }
657707
public void error(String msg, Object[] args)
  {

    String themsg = XSLMessages.createMessage(msg, args);

    throw new RuntimeException(XSLMessages.createMessage(
                                    XSLTErrorResources.ER_ELEMTEMPLATEELEM_ERR,
                                    new Object[]{ themsg }));
  }
825064
public static ObjectResult newErrorResult(String errMsg, String objID) {
        ObjectResult result = new ObjectResult();
        result.setStatus(Status.ERROR);
        result.setErrorMessage(errMsg);
        if (!Utils.isEmpty(objID)) {
            result.setObjectID(objID);
        }
        return result;
    }