Logging is an important aspect of every application. Knowing how to catch errors does not necessarily mean we are handling the faulty situation as best as we should. If we are not logging the right details, and passing them on to the right consumer, then we are not really handling the situation right.
Let's consider the following catch and generate user message example:
try {
//...
}
catch (\Exception $e) {
$messages[] = __('We can't add this item to your shopping cart right now.');
}
Let's consider the following example:
<?php
try {
//...
} catch (\Exception $e) {
$this->logger->critical($e);
$messages[] = __("We can't add this item to your shopping cart right now . ");
}
Both examples react to the exception by storing the message into a $messages variable, which is...