I'm trying to catch exceptions thrown when a soap api uses an invalid login credential using PHP toolkit.
The following code doesn not print either the message or the code :
catch(Exception $e) {
print $e->getMessage() . '<br />' . $e->getCode();
die;
}
however if I dump the $e exception, I get this whole object :
object(SoapFault)#10 (10) {
["message":protected]=>
string(56) "You have entered an invalid password. Please try again."
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(66) "***/PHP_Toolkit/rokutest/PHPtoolkit.php"
["line":protected]=>
int(1638)
["trace":"Exception":private]=>
array(3) {
[0]=>
array(6) {
["file"]=>
string(66) "***/PHP_Toolkit/rokutest/PHPtoolkit.php"
["line"]=>
int(1638)
["function"]=>
string(10) "__soapCall"
["class"]=>
string(10) "SoapClient"
["type"]=>
string(2) "->"
["args"]=>
array(5) {
[0]=>
string(7) "getList"
[1]=>
array(1) {
["baseRef"]=>
array(1) {
[0]=>
object(SoapVar)#7 (4) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(2) {
["internalId"]=>
int(3458745740)
["type"]=>
string(10) "salesOrder"
}
["enc_stype"]=>
string(9) "RecordRef"
["enc_ns"]=>
string(49) "urn:core_2011_2.platform.webservices.netsuite.com"
}
}
}
[2]=>
NULL
[3]=>
object(SoapHeader)#5 (5) {
["namespace"]=>
string(49) "urn:core_2011_2.platform.webservices.netsuite.com"
["name"]=>
string(8) "passport"
["data"]=>
object(SoapVar)#6 (2) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(4) {
["email"]=>
string(14) "***"
["password"]=>
string(10) "***"
["account"]=>
string(7) "***"
["role"]=>
object(SoapVar)#4 (4) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(1) {
["internalId"]=>
string(1) "3"
}
["enc_stype"]=>
string(9) "RecordRef"
["enc_ns"]=>
string(49) "urn:core_2011_2.platform.webservices.netsuite.com"
}
}
}
["mustUnderstand"]=>
bool(false)
["actor"]=>
string(42) "http://schemas.xmlsoap.org/soap/actor/next"
}
[4]=>
&array(0) {
}
}
}
[1]=>
array(6) {
["file"]=>
string(66) "***"
["line"]=>
int(1297)
["function"]=>
string(8) "makeCall"
["class"]=>
string(8) "nsClient"
["type"]=>
string(2) "->"
["args"]=>
array(2) {
[0]=>
string(7) "getList"
[1]=>
array(1) {
["baseRef"]=>
array(1) {
[0]=>
object(SoapVar)#7 (4) {
["enc_type"]=>
int(301)
["enc_value"]=>
array(2) {
["internalId"]=>
int(3458745740)
["type"]=>
string(10) "salesOrder"
}
["enc_stype"]=>
string(9) "RecordRef"
["enc_ns"]=>
string(49) "urn:core_2011_2.platform.webservices.netsuite.com"
}
}
}
}
}
[2]=>
array(6) {
["file"]=>
string(65) "***"
["line"]=>
int(22)
["function"]=>
string(7) "getList"
["class"]=>
string(8) "nsClient"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
array(1) {
[0]=>
object(nsRecordRef)#3 (4) {
["nsComplexObject_type"]=>
string(9) "RecordRef"
["nsComplexObject_namespace"]=>
string(49) "urn:core_2011_2.platform.webservices.netsuite.com"
["nsComplexObject_fields"]=>
array(2) {
["internalId"]=>
int(3458745740)
["type"]=>
string(10) "salesOrder"
}
["nsComplexObject_namespaces"]=>
NULL
}
}
}
}
}
["previous":"Exception":private]=>
NULL
["faultstring"]=>
string(56) "You have entered an invalid password. Please try again."
["faultcode"]=>
string(28) "soapenv:Server.userException"
["detail"]=>
object(stdClass)#8 (2) {
["invalidCredentialsFault"]=>
object(stdClass)#9 (2) {
["code"]=>
string(25) "INVALID_LOGIN_CREDENTIALS"
["message"]=>
string(56) "You have entered an invalid password. Please try again."
}
["hostname"]=>
string(39) "sb-partners-java004.svale.netledger.com"
}
}
How can I get to the error code (INVALID_LOGIN_CREDENTIALS) by using the caught exception $e ?