Skip to content

Commit dfb8287

Browse files
feat(debug and error): Split debug logic in 2 parts: debug and display error
1 parent b4efb9f commit dfb8287

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/AbstractBounce.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ abstract class AbstractBounce
2929
/** @var bool */
3030
protected $debug = false;
3131

32+
/** @var bool */
33+
protected $displayErrors = false;
34+
3235
/** @var LoggerInterface */
3336
protected $logger;
3437

@@ -60,6 +63,11 @@ public function setDebug(bool $debug)
6063
$this->debug = $debug;
6164
}
6265

66+
public function setDisplayErrors(bool $displayErrors)
67+
{
68+
$this->displayErrors = $displayErrors;
69+
}
70+
6371
protected function initLoggerHelper($logDirectoryPath, $loggerName): void
6472
{
6573
// Singleton for this function
@@ -112,12 +120,12 @@ protected function bounceCurrentIp()
112120
$this->logger->warning('', [
113121
'type' => 'UNKNOWN_EXCEPTION_WHILE_BOUNCING',
114122
'ip' => $ip,
115-
'messsage' => $e->getMessage(),
123+
'message' => $e->getMessage(),
116124
'code' => $e->getCode(),
117125
'file' => $e->getFile(),
118126
'line' => $e->getLine(),
119127
]);
120-
if ($this->debug) {
128+
if ($this->displayErrors) {
121129
throw $e;
122130
}
123131
}

src/StandAloneBounce.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,12 @@ public function safelyBounce(): void
363363
} catch (\Exception $e) {
364364
$this->logger->error('', [
365365
'type' => 'EXCEPTION_WHILE_BOUNCING',
366-
'messsage' => $e->getMessage(),
366+
'message' => $e->getMessage(),
367367
'code' => $e->getCode(),
368368
'file' => $e->getFile(),
369369
'line' => $e->getLine(),
370370
]);
371-
if ($this->debug) {
371+
if ($this->displayErrors) {
372372
throw $e;
373373
}
374374
} finally {

0 commit comments

Comments
 (0)