以下代码引发了一个我无法捕获的异常,无论出于何种原因。
try {
$this->date = \Carbon\Carbon::parse($this->date)->toDateString();
}
catch (Exception $err) {
$this->date = \Carbon\Carbon::parse("January 1st 1900")->toDateString();
}
现在,如果我将它放在函数闭包中的路由文件中,它可以正常工作。它仅在从模型中调用时抛出异常。
exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (Summer 2015) at position 0 (S): The timezone could not be found in the database' in /home/vagrant/www/steamcompare/vendor/nesbot/carbon/src/Carbon/Carbon.php:222
有没有其他人遇到过碳这个问题?