(REF) Kernel::runSafe - When decoding exceptions, check API_Exception before PEAR_Exc...
authorTim Otten <totten@civicrm.org>
Tue, 17 May 2022 21:32:19 +0000 (14:32 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 17 May 2022 21:32:19 +0000 (14:32 -0700)
API_Exception is narrower, and we may want API_Exception to become a subclass of PEAR_Exception

Civi/API/Kernel.php

index 70395abd76810e223b4c514092ce4e969889e23d..96cc6120fc5f025bd31ba85dc70a032e61eff04d 100644 (file)
@@ -86,12 +86,12 @@ class Kernel {
         $this->dispatcher->dispatch('civi.api.exception', new ExceptionEvent($e, NULL, $apiRequest, $this));
       }
 
-      if ($e instanceof \PEAR_Exception) {
-        $err = $this->formatPearException($e, $apiRequest);
-      }
-      elseif ($e instanceof \API_Exception) {
+      if ($e instanceof \API_Exception) {
         $err = $this->formatApiException($e, $apiRequest);
       }
+      elseif ($e instanceof \PEAR_Exception) {
+        $err = $this->formatPearException($e, $apiRequest);
+      }
       else {
         $err = $this->formatException($e, $apiRequest);
       }