There have been cases where I had to make use of methods that throw an exception in case of an error, but the exception would stop the execution of script , which would be something undesirable.
For example, I have a system where, when the student registers the request, an email is sent. The function that sends the email throws the exception. However, since the exception would stop the registration, I preferred to use an empty catch. It was not as important to send the email as the request was registered.
So I did something like this:
try{
Mail::create('email.aluno')->send($callback);
} catch (\Exception $e) {
// Se não enviar o e-mail por conta de um erro
// continue o script
// Não vamos interromper esse momento tão importante
}
$usuario->fill($dados)->save();
Someone might say: Just take the exception from where it gets thrown. I do not do this, since changing the third party source code is not a good idea, because when I was updating the system, I would have to edit it again, and again and again ...
Is it a bad practice to use an empty% void so nothing happens when the exception occurs?
Would this be an anti-default?
Is there a specific name for this type of operation?
Is there a risk in doing such an operation?