Answer the question
In order to leave comments, you need to log in
Breaking a call chain in Laravel?
Good evening. For example, there is a controller HomeController , it calls the methodA method of class A , which, in turn, calls the methodB method of class B and so on up to class X. If everything is ok, then the methodX method generates a response that is passed along the chain back to the Home controller. In addition, each method performs some kind of manipulation with this data (or returns other data). But, if an error occurs, the class generates an object (eg ErrorClass ) with the error and some additional parameters, which must be serialized and returned as a Response.
The problem is that when passing through this chain, you will have to check whether the method's response is an instance of ErrorClass . Of course, you can do this:
echo serialize($object);
die();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question