fix: log swallowed exceptions in date parsing and webhook
This commit is contained in:
@@ -163,7 +163,12 @@ final class MailjetNewsletterWebhookController extends AbstractController
|
|||||||
if (true === is_string($value) && '' !== trim($value)) {
|
if (true === is_string($value) && '' !== trim($value)) {
|
||||||
try {
|
try {
|
||||||
return new \DateTimeImmutable($value);
|
return new \DateTimeImmutable($value);
|
||||||
} catch (\Throwable) {
|
} catch (\Throwable $e) {
|
||||||
|
$this->logger->debug('Could not parse event timestamp from Mailjet webhook payload', [
|
||||||
|
'value' => $value,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Form\Service;
|
|||||||
|
|
||||||
use App\Form\Model\BookingDto;
|
use App\Form\Model\BookingDto;
|
||||||
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles processing of the dateOfBirth field for booking participants.
|
* Handles processing of the dateOfBirth field for booking participants.
|
||||||
@@ -21,10 +22,14 @@ use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
|||||||
* - Handles empty selections (converting them to null)
|
* - Handles empty selections (converting them to null)
|
||||||
* - Updates the participant's dateOfBirth property
|
* - Updates the participant's dateOfBirth property
|
||||||
*
|
*
|
||||||
* Dependencies: None (this is a base field that other handlers may depend on)
|
* Dependencies: Other handlers may depend on this field being processed first (age-based visibility).
|
||||||
*/
|
*/
|
||||||
class ParticipantDateOfBirthFieldHandler extends AbstractParticipantFieldHandler
|
class ParticipantDateOfBirthFieldHandler extends AbstractParticipantFieldHandler
|
||||||
{
|
{
|
||||||
|
public function __construct(private readonly LoggerInterface $logger)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the form field name this handler processes.
|
* Returns the form field name this handler processes.
|
||||||
*
|
*
|
||||||
@@ -118,7 +123,11 @@ class ParticipantDateOfBirthFieldHandler extends AbstractParticipantFieldHandler
|
|||||||
|
|
||||||
return new \DateTimeImmutable($dateString);
|
return new \DateTimeImmutable($dateString);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Invalid date components (e.g., Feb 31, invalid year)
|
$this->logger->debug('Invalid date of birth components submitted', [
|
||||||
|
'date_string' => $dateString,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,7 +147,10 @@ class ParticipantDateOfBirthFieldHandler extends AbstractParticipantFieldHandler
|
|||||||
try {
|
try {
|
||||||
return new \DateTimeImmutable($value);
|
return new \DateTimeImmutable($value);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Invalid date format, return null
|
$this->logger->debug('Invalid date of birth string submitted', [
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user