Just made a simple test on production to try and figure this out:
Route::get('test', function() {
try {
return \Carbon\Carbon::parse(
request()->query('date', 'now')
)->toDateString();
} catch (\Throwable $throwable) {
return $throwable->getMessage();
}
});
- When I visit
/test, I see "2022-05-07" ✅ - When I visit
/test?date=01-02-2020, I see "2020-02-01" ✅ - When I visit
/test?date=15/07/2021, I see "Could not parse '15/07/2021': Failed to parse time string (15/07/2021) at position 0 (1): Unexpected character" ✅
All good so far...
- Next, I changed
return $throwable->getMessage();toreturn $throwable->thisFunctionDoesNotExist();: - When I visit
/test?date=15/07/2021, I correctly see my application's error page ✅
Final test:
- Remove all
try { ... } catch { ... }statements from the function... - ...and I just get a blank white page ❌
Can't think what to try next — any thoughts?