diff --git a/wsclient.inc b/wsclient.inc
index 4040b06..f5ae24b 100644
--- a/wsclient.inc
+++ b/wsclient.inc
@@ -225,15 +225,29 @@ abstract class WSClientEndpoint implements WSClientEndpointInterface {
  * Custom exception class to enhance default PHP exceptions.
  */
 class WSClientException extends Exception {
-
+  protected $response;
+    
   /**
    * @param $msg
    *   The exception message containing placeholder as t().
    * @param $args
    *   Replacement arguments such as for t().
    */
-  function __construct($msg, $args = array()) {
+  function __construct($msg, $args = array(), $code = 0, $response = NULL, $exception = NULL) {
     $message = t($msg, $args);
-    parent::__construct($message);
+    parent::__construct($message, $code);
+    
+    $this->response = $response;
+  }
+  
+  /**
+   * Gets the response object, if any.
+   */
+  public function getResponse() {
+    $response = $this->response;
+    if (is_object($response)) {
+      $response = clone $response;
+    }
+    return $response;
   }
 }
diff --git a/wsclient_rest/wsclient_rest.module b/wsclient_rest/wsclient_rest.module
index caa426d..571e2ad 100644
--- a/wsclient_rest/wsclient_rest.module
+++ b/wsclient_rest/wsclient_rest.module
@@ -86,7 +86,7 @@ class WSClientRESTEndpoint extends WSClientEndpoint {
       return $response;
     }
     catch (HttpClientException $e) {
-      throw new WSClientException('Error invoking the REST service %name, operation %operation: %error', array('%name' => $this->service->label, '%operation' => $operation_name, '%error' => $e->getMessage()));
+      throw new WSClientException('Error invoking the REST service %name, operation %operation: %error', array('%name' => $this->service->label, '%operation' => $operation_name, '%error' => $e->getMessage()), $e->getCode(), $e->getResponse());
     }
   }
 
diff --git a/wsclient_soap/wsclient_soap.module b/wsclient_soap/wsclient_soap.module
index d78da88..6af87da 100644
--- a/wsclient_soap/wsclient_soap.module
+++ b/wsclient_soap/wsclient_soap.module
@@ -74,7 +74,7 @@ class WSClientSOAPEndpoint extends WSClientEndpoint {
       return $response;
     }
     catch (SoapFault $e) {
-      throw new WSClientException('Error invoking the SOAP service %name, operation %operation: %error', array('%name' => $this->service->label, '%operation' => $operation, '%error' => $e->getMessage()));
+      throw new WSClientException('Error invoking the SOAP service %name, operation %operation: %error', array('%name' => $this->service->label, '%operation' => $operation, '%error' => $e->getMessage()), $e->faultcode, $e->detail);
     }
   }
 }
