As JError is deprecated can we use here:

```php
throw new Exception($e->getMessage(), 500);
```