Good way of Exception Handeling

Posted 1 year ago by ImArtur

Hallo there,

Right now I'm building a API for the app. How should I handle exceptions? After some time I noticed that returning something like:


 if(!auth()->validate($credentials)){
                    return response()->json( 'password did not match',500);
        }

does not work well, especially when the application is growing. I could add exception to Handler.php, but what if I have for example 100 exceptions? Can I split the code in handler so it stays readable? If so how? Tutorials also would help.

Thanks.

Please sign in or create an account to participate in this conversation.