/** * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object) */ public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String errorType = asString("ErrorResponse/Error/Type", in, xpath); String requestId = asString("ErrorResponse/RequestId", in, xpath); String message = asString("ErrorResponse/Error/Message", in, xpath); AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("Receiver")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("Sender")) { ase.setErrorType(ErrorType.Client); } return ase; }
@Test public void testParseErrorCode() throws Exception { Document xmlDoc = new DocumentImpl(); Element root = xmlDoc.createElement("ErrorResponse"); Element error = xmlDoc.createElement("Error"); Element code = xmlDoc.createElement("Code"); code.appendChild(xmlDoc.createTextNode("TestCode")); error.appendChild(code); root.appendChild(error); xmlDoc.appendChild(root); StandardErrorUnmarshaller seu = new StandardErrorUnmarshaller(); assertEquals("TestCode", seu.parseErrorCode(xmlDoc)); }
/** * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object) */ @Override public AmazonServiceException unmarshall(Node in) throws Exception { String errorCode = parseErrorCode(in); String errorType = XpathUtils.asString("ErrorResponse/Error/Type", in); String requestId = XpathUtils.asString("ErrorResponse/RequestId", in); String message = XpathUtils.asString("ErrorResponse/Error/Message", in); AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if ("Receiver".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Service); } else if ("Sender".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Client); } return ase; }
/** * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object) */ public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String errorType = asString("ErrorResponse/Error/Type", in, xpath); String requestId = asString("ErrorResponse/RequestId", in, xpath); String message = asString("ErrorResponse/Error/Message", in, xpath); AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("Receiver")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("Sender")) { ase.setErrorType(ErrorType.Client); } return ase; }
/** * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object) */ @Override public AmazonServiceException unmarshall(Node in) throws Exception { String errorCode = parseErrorCode(in); String errorType = XpathUtils.asString("ErrorResponse/Error/Type", in); String requestId = XpathUtils.asString("ErrorResponse/RequestId", in); String message = XpathUtils.asString("ErrorResponse/Error/Message", in); AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if ("Receiver".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Service); } else if ("Sender".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Client); } return ase; }
/** * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object) */ @Override public AmazonServiceException unmarshall(Node in) throws Exception { String errorCode = parseErrorCode(in); String errorType = XpathUtils.asString("ErrorResponse/Error/Type", in); String requestId = XpathUtils.asString("ErrorResponse/RequestId", in); String message = XpathUtils.asString("ErrorResponse/Error/Message", in); AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if ("Receiver".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Service); } else if ("Sender".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Client); } return ase; }
/** * @see com.amazonaws.transform.Unmarshaller#unmarshall(java.lang.Object) */ public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String errorType = asString("ErrorResponse/Error/Type", in, xpath); String requestId = asString("ErrorResponse/RequestId", in, xpath); String message = asString("ErrorResponse/Error/Message", in, xpath); AmazonServiceException ase = newException(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("Receiver")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("Sender")) { ase.setErrorType(ErrorType.Client); } return ase; }