Questions tagged [laravel-exceptions]

24 questions
5
votes
3 answers

Laravel 5.7 How to Log 404 With URL

I want to log 404 errors in Laravel 5.7, but I don't understand how to turn this on. Additional to logging 404 errors, I'd like to log the URL that was requested. Other errors are logged…
eskimo
  • 2,421
  • 5
  • 45
  • 81
4
votes
2 answers

Laravel error handling, get_class vs instanceof

In the following code in app/Exceptions/Handler.php, the first one doesn't work but the second one does. dd(get_class($exception)); outputs "Illuminate\Database\Eloquent\ModelNotFoundException". The first one is similar to the doc. How can I make…
shin
  • 31,901
  • 69
  • 184
  • 271
2
votes
3 answers

Laravel Exception 405 MethodNotAllowed

I'm trying to create a new "Airborne" test in my program and getting a 405 MethodNotAllowed Exception. Routes Route::post('/testing/{id}/airbornes/create', [ 'uses' => 'AirborneController@create' ]); Controller public function create(Request…
2
votes
3 answers

Laravel custom exception

Before posting this question I have searched internet for appropriate answers but got none.These are my following questions: 1) How to throw exception without try catch in laravel controller and get exception in the view of the called…
Rahul
  • 2,374
  • 2
  • 9
  • 17
2
votes
1 answer

laravel: Argument 1 passed to App\Exceptions\CustomException::report() must be an instance of Exception,

I have created a custom exception class in Laravel 5.2. It works well till laravel 5.4. When Im trying to use the same custom exception class with laravel 5.5 it is throwing following error. Type error: Argument 1 passed to…
Lakshmaji
  • 899
  • 2
  • 14
  • 30
1
vote
1 answer

Understanding Laravel exception handling catching exceptions in the controller that have been thrown in service layer

Trying to create an API server with laravel. I have seen many tutorials that catch the exception thrown in the service layer. However, in Laravel, we have an option to create a custom error handler that has a render function that encapsulates the…
user275157
  • 1,332
  • 4
  • 23
  • 45
1
vote
0 answers

Why I failed to catch ModelNotFoundException ths error in controller block?

In laravel 9 I have ProductCardReport component which is on blade form and data are retrieved from ReportProduct class. I got data with firstOrFail in this class and I failed to catch this error in controller block. I have in ProductController…
mstdmstd
  • 2,195
  • 17
  • 63
  • 140
1
vote
1 answer

How to checks raised exceptions in phpunit tests?

In laravel 9.26.1 app I make tests with phpunit ^9.5.10 and I want to make checks on raised exceptions on login with invalid credentials In app/Http/Requests/Auth/LoginRequest.php I see : public function authenticate() { …
mstdmstd
  • 2,195
  • 17
  • 63
  • 140
1
vote
0 answers

Laravel - Seeing Symfony Exception page instead of Spatie Ignition

In my composer file I have "spatie/laravel-ignition": "^1.2" however when an exception is thrown I am seeing the Symfony exception page rather than Ignition (shown below). .env has the following: APP_ENV="local" APP_DEBUG="true" Config files are…
J Foley
  • 1,038
  • 1
  • 17
  • 30
1
vote
2 answers

Laravel: disallow direct access to Post method by users

I have a website which is developed in Laravel. Problem: I have a route method (POST) Route::post('/profile/edit/save', 'ProfileController@save'); if I enter this url "mywebsite.com/profile/edit/save" I get an error Symfony \ Component \…
Abdes
  • 926
  • 1
  • 15
  • 27
0
votes
1 answer

How to make custom exception in http unit test?

On laravel site in controller I catch custom KeyIsNotProvidedException Exception: method(); ... } catch (KeyIsNotProvidedException $e) { return response()->json([ …
Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91
0
votes
2 answers

custom exception of Laravel is not working as expected

I am working with the Laravel 9 application. I have created a custom Exception. I want to report the General Exception to the sentry and this custom Exception to another vendor like Papertrail. The Handler.php is not calling the reportable closure…
Sachin Kumar
  • 3,001
  • 1
  • 22
  • 47
0
votes
1 answer

How to catch custom error raised in method of object?

On laravel 9 site in my custom class method raise custom error with error message
Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91
0
votes
1 answer

how to add exception in laravel migration?

I'm doing a migration and I want the execution of "artisan migrate" to stop until a field does not have the value 'CONTACT_INFO' inside. What I want to do is an exception when I detect that this value is not there. public function up() { …
0
votes
1 answer

Manually throw Laravel ValidationException VS FormRequestValidationException

Is there any difference when I throw ValidationException manally and when ValidationException is thrown by laravel from FormRequest. Following code will clear the problem UserController.php public function checkEmailExists(Request $request){ try…
Ahmar Arshad
  • 477
  • 1
  • 10
  • 22
1
2