/** * Register the service provider. * * @return void */ public function register() { /** * ValidationException handler * * This catches ValidationException and Logs it, then returns the users back * */ App::error(function (ValidationException $e, $code, $fromConsole) { Log::error('ValidationException - ' . $e->getMessage()); return Redirect::back()->withInput()->withErrors($e->get()); }); App::error(function (QueryException $e, $code, $fromConsole) { Log::error('QueryException - ' . $e->getMessage()); return $this->showError(3, $e); }); /** * TokenMismatchException handler * * Handle CSRF mismatches */ App::error(function (TokenMismatchException $e, $code, $fromConsole) { Log::error('TokenMismatchException: ip: ' . Request::ip()); Site::set('title', 'Oops!'); return $this->showError(2, $e); }); /** * ModelNotFoundException handler * * What happens if a specific model cant be found. */ App::error(function (ModelNotFoundException $e, $code, $fromConsole) { Messages::add('error', 'That Id is invalid'); if (URL::previous() !== URL::to('')) { return Redirect::back(); } else { return Redirect::to('admin'); } }); }
protected function setTitle($title) { \Orchestra\Site::set('title', $title); }