2013-06-21 53 views
0

我在Laravel 4應用程序中遇到異常捕捉問題。 我有這樣Route::get('/articles/edit/{id}', '[email protected]')->where('id', '[0-9]+');在Laravel 4中捕捉異常4

路線現在,如果我去localhost:8000/articles/edit/6,它工作正常,但如果我去localhost:8000/articles/edit/6a失敗where子句,因爲它比其他數字字符,並拋出NotFoundHttpException

我試圖從內部編輯函數以及從路由文件中捕獲此異常,但沒有運氣。由於我剛剛開始使用Laravel 4,我希望能在這裏找到一些幫助,因爲谷歌沒有幫助

回答

1

您可以使用App::missingNotFoundHttpException定義自定義處理程序。來自documentation

App::missing(function($exception) 
{ 
    return Response::view('errors.missing', array(), 404); 
}); 
+0

作品。大。謝謝 –