Remove a couple of instances of fatal errors in favour of throwing exceptions
authoreileen <emcnaughton@wikimedia.org>
Sat, 27 Apr 2019 04:28:33 +0000 (16:28 +1200)
committereileen <emcnaughton@wikimedia.org>
Sat, 27 Apr 2019 04:28:41 +0000 (16:28 +1200)
https://lab.civicrm.org/dev/core/issues/560

CRM/Core/BAO/File.php

index c9a1265d671ed7dec42d0752e4e6e171cd2a8549..c2c06bd279fbc166fe15af0537e3f7c2afe6d840 100644 (file)
@@ -210,7 +210,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
     $fileDAO = new CRM_Core_DAO_File();
     $fileDAO->id = $fileID;
     if (!$fileDAO->find(TRUE)) {
-      CRM_Core_Error::fatal();
+      throw new CRM_Core_Exception(ts('File not found'));
     }
 
     // lets call a pre hook before the delete, so attachments hooks can get the info before things
@@ -226,7 +226,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
     $entityFileDAO->entity_table = $tableName;
 
     if (!$entityFileDAO->find(TRUE)) {
-      CRM_Core_Error::fatal(sprintf('No record found for given file ID - %d and entity ID - %d', $fileID, $entityID));
+      throw new CRM_Core_Exception(sprintf('No record found for given file ID - %d and entity ID - %d', $fileID, $entityID));
     }
 
     $entityFileDAO->delete();