Skip to content

Commit

Permalink
Merge pull request #588 from rollbar/4.0/update-response-handler-inte…
Browse files Browse the repository at this point in the history
…rface

Updated the typing and comments for the `ResponseHandlerInterface`
  • Loading branch information
danielmorell committed Jan 4, 2023
2 parents f0f665d + 039f54a commit 9dfca30
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ public function wait(string $accessToken, $max = 0): void
$this->sender->wait($accessToken, $max);
}

public function handleResponse(Payload $payload, mixed $response): void
public function handleResponse(Payload $payload, Response $response): void
{
if (!is_null($this->responseHandler)) {
$this->verboseLogger()->debug(
Expand Down
17 changes: 16 additions & 1 deletion src/ResponseHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@

use Rollbar\Payload\Payload;

/**
* The response handler interface allows the processing of responses from the Rollbar service after a log message or
* error report has been sent to Rollbar. A custom response handler FQCN may be passed in the config array with the key
* "responseHandler". The custom handler class constructor may be a single argument by including it in the config array
* with the "responseHandlerOptions" key. If the "responseHandlerOptions" key does not exist an empty array will be
* passed to the constructor.
*/
interface ResponseHandlerInterface
{
public function handleResponse(Payload $payload, mixed $response): void;
/**
* The handleResponse method is called with the response from the Rollbar service after an error or log message has
* been sent.
*
* @param Payload $payload The payload object that was sent to Rollbar.
* @param Response $response The response that was returned. If the response status code is 0, it likely represents
* an ignored error that was never sent.
*/
public function handleResponse(Payload $payload, Response $response): void;
}
6 changes: 3 additions & 3 deletions src/RollbarLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,12 @@ public function verboseLogger(): LoggerInterface
/**
* Calls the custom 'responseHandler', config if it exists.
*
* @param Payload $payload The payload that was sent.
* @param mixed $response The response from the Rollbar service.
* @param Payload $payload The payload that was sent.
* @param Response $response The response from the Rollbar service.
*
* @return void
*/
protected function handleResponse(Payload $payload, mixed $response): void
protected function handleResponse(Payload $payload, Response $response): void
{
$this->config->handleResponse($payload, $response);
}
Expand Down

0 comments on commit 9dfca30

Please sign in to comment.