Hi Guys,
I have an abstract class which I use to display messages. i have a piece of code surrounded by a try / catch block but it seems the message is never passed to the Exception. When I put a hard coded message in the exception it works.
Can I anybody help me with this. Heres my code
// The Abstract Class
namespace App\Models;
asbstract class Messages
{
const ERROR_MSG = "This is just an error message";
const LOGIN_DENIED = "Login has been denied";
}
In my controller action I have this :
namespace App\Controllers;
use App\Messages;
class AuthController extends BaseController
{
public function loginAction()
{
try{
$loggedIn = false;
if (!$loggedIn) {
throw new \Exception(Messages::LOGIN_DENIED);
}
} catch(\Exception $e) {
// The Message is never displayed
echo $e->getMessage();
}
}
}
Please help. Thanks