Last active
March 25, 2019 17:36
-
-
Save marcusirgens/16bb28b153fc802db6e64e0b03bcfbea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Catch any exceptions, log them and rethrow the exception | |
* | |
* @see \Vendor\Library\Class::sendRequest() | |
* @param $subject | |
* @param callable $next | |
* @param mixed ...$args | |
* @return mixed | |
* @throws \Throwable | |
*/ | |
public function aroundSendRequest( | |
\Vendor\Library\Class $subject, | |
callable $next, | |
...$args | |
) { | |
try { | |
return $next(...$args); | |
} catch (\Throwable $throwable) { | |
$this->logger->error( | |
"Error while making request to Vendor: {message}", | |
[ | |
"message" => $throwable->getMessage(), | |
"exception" => $throwable, | |
"request_data" => $args | |
] | |
); | |
throw $throwable; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment