title: Catch exception and redirect
body: <p>I'm making an installation script for a Laravel application and I'm trying to create admin account as one of the installation steps. When an error arises, the application should redirect back to the same page with an alert message, but Laravel shows error message and stops the application:</p>
  
  <pre><code>public function postAdmin() {
  
  $validation_rules = array(
      'username' =&gt; 'required|min:4|alpha_dash|unique:users',
      'email' =&gt; 'required|email|unique:users',
      'password' =&gt; 'required|min:4',
      );
  
  $validator = Validator::make(Input::all(), $validation_rules);
  
  if ($validator-&gt;fails()) {
      return Redirect::to('install/admin')
      -&gt;withInput()
      -&gt;withErrors($validator);
  }
  
  else {
  
      try {
       $username = Input::get('username');
       $email = Input::get('email');
       $password = Hash::make(Input::get('password'));
  
       $admin_user = new User;
       $admin_user-&gt;username = $username;
       $admin_user-&gt;email = $email;
       $admin_user-&gt;password = $password;
       $admin_user-&gt;admin = 1;
  
       $user_data_saved = $admin_user-&gt;save();
  
       if ($user_data_saved) {
          Auth::attempt(array('email' =&gt; Input::get('email'), 'password' =&gt; Input::get('password')));
          return Redirect::to('install/finish')-&gt;with('success', "Admin account created");
      } 
      else {
          return Redirect::to('install/admin')
          -&gt;with('error', 'Error adding admin info');
      }
  }
  catch(Exception $e) {
      return Redirect::to('install/admin')-&gt;with('error', "Error creating admin account");
  }
  </code></pre>
  
  <p>}
  }</p>
  
  <p>Is it possible to check for errors using try/catch and redirect if an error arises and how?</p>