CRM_Core_Error::formatFooException - Don't bomb on 'Error'
authorTim Otten <totten@civicrm.org>
Tue, 3 Nov 2020 05:54:45 +0000 (21:54 -0800)
committerTim Otten <totten@civicrm.org>
Tue, 3 Nov 2020 06:06:18 +0000 (22:06 -0800)
commit614fcec464f2f16f67ee4418897e080d7daa5722
tree346ee592f50515cb0c4dc23cfc66066afcdee184
parentfef7e3fc290f63370bc9f9409315a1cc4565ebd9
CRM_Core_Error::formatFooException - Don't bomb on 'Error'

PHP 7 updated the class hierarchy for exceptions. The top-level types for exceptions are now:

* class Throwable
* class Error extends Throwable
* class Exception extends Throwable

This patch fixes a problem when logging `Error`s, as in

```php
Civi::log()->warning('There was a problem', [
  'exception' => $e
]);
```

Before
------

If `$e` is an `Error`, it fails to log.

After
-----

It works whether `$e` is an `Error` or `Exception`.

See also: https://www.php.net/manual/en/language.errors.php7.php
CRM/Core/Error.php
tests/phpunit/CRM/Core/ErrorTest.php