Skip to content

Commit

Permalink
Adds a few more information to the error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-schoendorn committed May 9, 2018
1 parent 50f5e9f commit e8b5f26
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/LocalCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,38 @@ public function validate(array $submittedData): FormData
}
catch (\Throwable $throwable) {
if ($this->logger) {
$this->logThrowable($throwable);
$this->logThrowable($throwable, $submittedData);
}
throw $throwable;
}

return $formData;
}

private function logThrowable(\Throwable $throwable)
private function logThrowable(\Throwable $throwable, array $submittedData)
{
switch (true) {
case $throwable instanceof TuringTestException:
$this->logger->debug('LocalCaptcha: Turing test failed', [ 'exception' => $throwable ]);
$this->logger->debug('LocalCaptcha: Turing test failed', [
'formId' => $this->formId,
'exception' => $throwable,
'submittedData' => $submittedData
]);
break;

case $throwable instanceof LocalCaptchaException:
$this->logger->error('LocalCaptcha: Error', [ 'exception' => $throwable ]);
$this->logger->error('LocalCaptcha: Error', [
'formId' => $this->formId,
'exception' => $throwable
]);
break;

// @codeCoverageIgnoreStart
default:
$this->logger->critical('LocalCaptcha: Unexpected exception', [ 'exception' => $throwable ]);
$this->logger->critical('LocalCaptcha: Unexpected exception', [
'formId' => $this->formId,
'exception' => $throwable
]);
break;
// @codeCoverageIgnoreEnd
}
Expand Down

0 comments on commit e8b5f26

Please sign in to comment.