O
O
Oleg Matrozov2016-05-16 14:38:11
Yii
Oleg Matrozov, 2016-05-16 14:38:11

Why modern frameworks refuse recoverable error?

Actually the question is in the title.
In native php, calling a function, for example, trigger_error('My non-critical error') will cause this information to be saved to the log and processed by all sorts of handlers, including external types newrelic. Moreover, if I do not manually call this function with E_USER_ERROR, the program will continue to run (again, according to the php documentation). But if we take a framework (Yii1/2, Laravel), then we will see that the creation of errors like E_USER_NOTICE/E_USER_WARNING will already cause the application to terminate. Those. not only did they throw out the revoverable error class, they also changed the behavior of the standard php function.
A simple example of why recoverable errors are needed:
There is a service in the vacuum of sending SMS to which two gateways are connected (main and spare). The failure to connect to the primary gateway and send through the alternate is a recoverable error as there was no denial of service. Failure of both gateways is already a critical error.
So, in modern frameworks, I can no longer just throw myself a recoverable error and have to fence the garden just to monitor the fact of the failure of the main gateway.
Question one: why did they do this?
Sorry, it got a little burnt.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rikcon, 2016-05-16
@Rikcon

try/catch?
In PHP7, it seems like they cut out warnings and errors, they are now all exceptions.
php.net/manual/en/language.errors.php7.php

S
Sergey, 2016-05-16
Protko @Fesor

that generating errors like E_USER_NOTICE/E_USER_WARNING will already cause the application to terminate.

error reporting level is still in your control. In general, in production code, we should not have notices or warnings, but sometimes it's easier to just turn it off.
In general, things are moving towards more explicit error handling. It remains only to remove the error suppression operator.
Your situation is fine with exceptions.
Learn to use exceptions. In php7, in principle, even parsing errors now throw exceptions .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question