0

I am trying to get faultstring from SoapFaultException class but can only get faultcode but not faultstring. Code snipped :

    public static Object querySf(String query , PartnerConnection pc) throws Exception  {
        
        try {
            return pc.query(query);
        } catch (ConnectionException e) {
            // TODO Auto-generated catch block
            logger.warn("I am i this");
            SoapFaultException sf = (SoapFaultException)e;
            logger.warn(sf.getFaultCode())

    }

Adding link to raw class: https://github.com/forcedotcom/wsc/blob/master/src/main/java/com/sforce/ws/SoapFaultException.java

0

SoapFaultException extends ConnectionException which extends Exception.

That means default Exception (Throwable) methods are available with SoapFaultException like getCause(), getMessage(), and getStackTrace().

Try calling those instead, specifically getMessage() which returns the message passed to the Exception constructor:

public static Object querySf(String query , PartnerConnection pc) throws Exception  {        
    try {
        return pc.query(query);
    } catch (ConnectionException e) {
        // TODO Auto-generated catch block
        logger.warn("I am i this");
        SoapFaultException sf = (SoapFaultException)e;
        logger.warn(sf.getMessage());
        logger.warn(sf.getCause());
    }
}
| improve this answer | |
  • getMessage was coming null. – Piyush Kalra Jul 16 at 13:37
  • It's possible no message is supplied and in that case, the message will be null. Have you tried calling getMessage on the initially caught exception (ConnectionException)? – nbrown Jul 16 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.