I currently have a try/catch around a line of code but when it errors out It's not properly printing out the error. Currently:
try { // code here } catch (\Exception $e) { return Redirect::back() ->withErrors($e->getResponse()->getBody()->getContents()["message"]); } prints:
{
Now if I use:
return Redirect::back()->withErrors($e->getResponse()->getBody()->getContents()); then I get:
{ "message":user doesn't exist }
How can I change this to, upon error, only print "user doesn't exist"?
var_dump($e->getResponse()->getBody()->getContents());giving you?""" {\n "message": "User doesn't exist."\n }\n """json_decode()