Search code examples
phpsquare-connect

How to access Square connect error "detail" with PHP?


I am trying to retrieve the detail of a Square API Error object using the PHP SDK.

This is the code I'm using:

$err = $e->getResponseBody()->errors['0']->detail;

This works, but is there a better way to return error message(s)? I have read error related info in the documentation but was unable to find any code to get the detail property with PHP. Thanks!


Solution

  • You've got the right idea, but you might want to use getDetail() instead of ->detail