'Canvas LMS API .Catching 404 error in http responses in Laravel

I am using canvas LMS API service. My problem is: Courses, users etc. I'm making an http request for, and let's assume that this incoming request is a user profile. Our user has the 10th ID number and there is no problem. But if a non-existent ID number is entered, my variables have null values ​​and therefore I get an error in the blade. How can I write a method like "findOrFail" method in all controllers I make API request? Canvas API returns error response.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source