Catching exceptions from Guzzle

前端 未结 8 1784
情歌与酒
情歌与酒 2020-11-30 22:07

I\'m trying to catch exceptions from a set of tests I\'m running on an API I\'m developing and I\'m using Guzzle to consume the API methods. I\'ve got the tests wrapped in a

8条回答
  •  悲&欢浪女
    2020-11-30 22:47

    In my case I was throwing Exception on a namespaced file, so php tried to catch My\Namespace\Exception therefore not catching any exceptions at all.

    Worth checking if catch (Exception $e) is finding the right Exception class.

    Just try catch (\Exception $e) (with that \ there) and see if it works.

提交回复
热议问题