title: Catch FatalErrorException PHP
body: <p><strong>Hi everyone!</strong> In my Laravel application I have a upload function for an Excel file. I got this code from the web and adjusted it to my application. The problem is, it doesn't catch a fatal error exception which is produced when the user submits a file, but hasn't selected a file. I don't understand why it is not being caught. I will add a part of my controller. </p>
  
  <pre><code> public function upload() {
          $file = array('thefile' =&gt; Input::file('thefile'));
          $rules = array('excel' =&gt; 'excel');
          $validator = Validator::make($file, $rules);
          if ($validator-&gt;fails()) {
              return Redirect::to('UploadExcelFile')-&gt;withInput()-&gt;withErrors($validator);
          }
          else {
              try{
              // FatalErrorException happens in this line!
              if (Input::file('thefile')-&gt;isValid()) {
                  $destinationPath = 'uploads';
                  $fileName = Input::file('thefile')-&gt;getClientOriginalName();
                  Input::file('thefile')-&gt;move($destinationPath, $fileName);
                  Session::flash('success', 'Upload successfully');
                  $fileNameJSON = exec("python /path/to/script/ExcelToJSON3.py $fileName"); // This returns a full path name of the JSON file that is made...
                  if ($fileNameJSON == null){
                      return Redirect::to('/dashboard/input');
                  }
                  else {
  
                  //      Getting the ID from the file that is uploaded
                  try {
                      $jsonDecode = json_decode(file_get_contents($fileNameJSON));
                  } catch (ErrorException $e){
                      return Redirect::to('/errorpage')-&gt;with(array('status'=&gt; 'ErrorException'));
                  }
  
  
  A lot of code for handling the data entered.... 
  
                  }catch (FatalErrorException $e){
                          return Redirect::to('/errorpage')-&gt;with(array('status'=&gt; 'FatalErrorException'));
  
              }    
          }
          return true;
      }
  </code></pre>
  
  <p>The error that is given:</p>
  
  <p><strong>FatalErrorException in UploadExcelFileController.php line 35:
  Call to a member function isValid() on a non-object</strong></p>
  
  <p>So, I don't understand why this code doesn't handle the error exception and how I could fix this! </p>