DivideBV / Postnl

Library to connect to PostNL's SOAP service called CIF
GNU General Public License v2.0
31 stars 40 forks source link

Undefined notices when parsing errors from webservice #65

Closed annuh closed 5 years ago

annuh commented 5 years ago

When the PostNL webservice returns an error, I'm getting undefined notices because the ExceptionData is not an array.

Notice Error: Trying to get property 'Description' of non-object in [/var/www/html/app/Vendor/dividebv/postnl/src/Postnl.php, line 566]

Notice Error: Trying to get property 'ErrorMsg' of non-object in [/var/www/html/app/Vendor/dividebv/postnl/src/Postnl.php, line 567]

Notice Error: Trying to get property 'ErrorNumber' of non-object in [/var/www/html/app/Vendor/dividebv/postnl/src/Postnl.php, line 568]

Notice Error: Trying to get property 'Description' of non-object in [/var/www/html/app/Vendor/dividebv/postnl/src/Postnl.php, line 566]

Notice Error: Trying to get property 'ErrorMsg' of non-object in [/var/www/html/app/Vendor/dividebv/postnl/src/Postnl.php, line 567]

Notice Error: Trying to get property 'ErrorNumber' of non-object in [/var/www/html/app/Vendor/dividebv/postnl/src/Postnl.php, line 568]

Notice Error: Trying to get property 'Description' of non-object in [/var/www/html/app/Vendor/dividebv/postnl/src/Postnl.php, line 566]

Notice Error: Trying to get property 'ErrorMsg' of non-object in [/var/www/html/app/Vendor/dividebv/postnl/src/Postnl.php, line 567]

Notice Error: Trying to get property 'ErrorNumber' of non-object in [/var/www/html/app/Vendor/dividebv/postnl/src/Postnl.php, line 568]

Debugging shows that $exception (HERE) has the following data:

SoapFault {#64
  #message: "Check CIFException in the detail section"
  #code: 0
  #file: "./app/Vendor/dividebv/postnl/src/LabellingClient.php"
  #line: 59
  +"faultstring": "Check CIFException in the detail section"
  +"faultcode": "s:CIF Framework Message Interceptor"
  +"detail": {#60
    +"CifException": {#61
      +"Errors": {#62
        +"ExceptionData": {#63
          +"Description": null
          +"ErrorMsg": "Validation failed for shipment: xxxx, Messages: xxx: {[xxxx] Receiver Street is required}"
          +"ErrorNumber": "1003"
        }
      }
    }
  }
  trace: {
    ./app/Vendor/dividebv/postnl/src/LabellingClient.php:59 { ā€¦}

  }
}
ameenross commented 5 years ago

This was already fixed, I'll release 2.0.0-beta2

annuh commented 5 years ago

Yes sorry, I just wanted to create a PR for this but then I saw it was already fixed. šŸ˜ƒ

Thank you! šŸ‘