我在该行添加了错误
$user = $account->users->fill($this->getUserData($request));
但是catch块永远不会被调用。改为Symfony\FatalErrorException
。
public function saveAccount($request, $listener){
$this->uploadFile($request, $listener);
DB::beginTransaction();
try {
$account = $this->update($this->getAccountData($request), $request->id);
$user = $account->users->fill($this->getUserData($request));
$user->push();
DB::commit();
return $listener->doRedirect(null, trans('account.success'));
} catch (\Exception $e) {
$this->rollBackUpload($rl,$ml);
DB::rollBack();
return $listener->doRedirect('error', trans('account.error'));
}
}
答案 0 :(得分:1)
为我做以下工作: 在App / Exception / Handler.php中 http://laravel.com/docs/5.0/errors#handling-errors
public function render($request, Exception $e){
if ($e instanceof FatalErrorException)
{
$errorsEx = explode("\n", $e->getMessage());
return redirect()->route('route')->with('errorsEx', $errorsEx);
}
return parent::render($request, $e);
}