You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using assert in my application and it works great! Thank you!
Where I have been running into trouble however is that I want to add logging so when an exception is thrown I can log it properly. I currently can log when a success happens inside the class, but I cannot get a log to be generated in the catch block.
I believe the issue is I simply do not know PHP well enough to do what I am attempting. Any guidance that can be given would be appreciated..
Here is what I am currently working with:
public function test($data): void {
try {
$this->logger->info("TESTING INFO LOG " );
Assert::isArray($data, 'POST `data` is not an array.');
Assert::keyExists($data, "id", "POST `id=#` is mandatory to pass this test");
}
catch (InvalidArgumentException $exception) {
$this->logger->critical("TESTING CRITICAL ERROR " );
throw new ValidationException($exception->getMessage());
}
}
Is this actually possible to do without changing the code within the assert class itself? I would rather not mess with the class as I am still learning PHP and all of the gotchas..
I have tested this in PHP 7.4 with Ubuntu 20.04..
The text was updated successfully, but these errors were encountered:
I have been using assert in my application and it works great! Thank you!
Where I have been running into trouble however is that I want to add logging so when an exception is thrown I can log it properly. I currently can log when a success happens inside the class, but I cannot get a log to be generated in the catch block.
I believe the issue is I simply do not know PHP well enough to do what I am attempting. Any guidance that can be given would be appreciated..
Here is what I am currently working with:
Is this actually possible to do without changing the code within the assert class itself? I would rather not mess with the class as I am still learning PHP and all of the gotchas..
I have tested this in PHP 7.4 with Ubuntu 20.04..
The text was updated successfully, but these errors were encountered: