Closed JmzTaylor closed 9 months ago
Changing the code to this seems to have fixed it.
Flight::map('error', function(TypeError $ex) {});
As far as I know, the error function should accept any parameter that extends Exception
and implements a Throwable
. I couldn't replicate the error here, it worked normally with an Exception
parameter.
<?php
require 'flight/Flight.php';
Flight::map('error', function(Exception $ex){
echo $ex->getMessage();
});
Flight::route('/', function(){
throw new ErrorException('Test ErrorException'); //It works
throw new Exception('Test Exception'); //It works
trigger_error('Test Trigger Error', E_USER_ERROR); //It works
});
Flight::start();
?>
FlightPHP also converts all thrown errors into ErrorException. Tested with #v2.0.1.
Since TypeError
extends Error
, I guess there is a throw new Error()
somewhere in your code, maybe? If I'm right, try using throw new ErrorException
instead...
I am getting this error when trying to catch exceptions. This is the line causing this error.