Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Exception notice slipping through try catch
  • Here's my code
    try{
     $time = Date::create_from_string($score['updated_at'], "mysql");
     $when = $time? Date::time_ago($time->get_timestamp()) : '';
    }catch(Exception $e){
     $when = "";
    }
    

    I'm using the REST controller but this is spilling into the output
    <strong>Notice:</strong> Input was not recognized by pattern. in APPPATH/classes/controller/api.php [190]: create_from_string<strong>Notice:</strong> Input was not recognized by pattern. in APPPATH/classes/controller/api.php [190]: create_from_string<strong>Notice:</strong> Input was not recognized by pattern. in APPPATH/classes/controller/api.php [190]: create_from_string
    

    Is there a way to catch this notice without having to disable error handeling for everything? I'm aware that sometimes the date string will come back with a bad value and want to ignore it.
  • Looks like you're on v1.1 release branch. This has been fixed in 1.1/develop (and will be part of the upcoming 1.2 release), where it was changed so it does throw an exception (UnexpectedValueException to be exact) instead of logging a notice. If you don't want to wait for 1.2, and don't want to change to 1.1/develop, you can cherry pick this change from https://github.com/fuel/core/blob/1.1/develop/classes/date.php.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion