Here's the code:
try{
//The exception is thrown.
throw new Exception('Parâmetros de consulta inválidos');
// and in the catch block it's caught successfully:
}catch(Exception $e){
echo $e->getMessage(); //This prints the message correctly.
$output = json_encode(array('msg'=>$e->getMessage()));
echo $output; //But this fails...displays {"msg":null}
}
What is the issue here?