Added exception logging.

Did php-cs-fixer move this around?

I usually write multi-condition ifs like so:
```php
if (
    $conditionOne
    && $conditionTwo
)
```

Also, I think it might be best to move all of this exception logging code into a private method.