27 questions
1
vote
2
answers
962
views
Laravel 12 custom Exception
I want to use different error pages for the admin panel and the frontend in Laravel 12. I created a custom exception class for this purpose, but I haven’t figured out how to activate or use it yet. ...
0
votes
3
answers
310
views
Handling Exceptions inside Pipeline
I'am kind of new to laravel and currently working with pipelines. As I know, if one step inside the Pipeline fail, the whole Pipeline get stopped at that step. That is exactly what I want, so I'am ...
0
votes
1
answer
23
views
Have I to define custom exception class ItemValidAccess in mehod?
On laravel 10 site I made a method which returns true or ItemValidAccess exception in case of invalid data :
/**
* Determine whether logged user have access to complete item
*
* @...
1
vote
1
answer
1k
views
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 ...
0
votes
1
answer
72
views
How to make custom exception in http unit test?
On laravel site in controller I catch custom KeyIsNotProvidedException Exception:
<?php
try {
$data = $this->method();
...
} catch (...
1
vote
2
answers
2k
views
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 ...
1
vote
0
answers
370
views
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 ...
0
votes
1
answer
374
views
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
<?php
class CustomClass
{
use Illuminate\Database\Eloquent\ModelNotFoundException;
...
0
votes
1
answer
617
views
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 ...
1
vote
1
answer
56
views
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 ...
1
vote
0
answers
525
views
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 ...
1
vote
1
answer
6k
views
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 ...
0
votes
1
answer
3k
views
Laravel Error in Logs Doesn't Tell Me What I Need to Fix
I'm getting an error in my Laravel logs almost everyday, but the error message doesn't tell me which one of my views or controllers is causing the error. It's a FormRequest.php error, so I know it's a ...
0
votes
0
answers
184
views
How may I call a blade view in a custom Http Exception? (Laravel 7)
I am looking to return a view from the HttpException that is triggered by my package's middleware, currently, it returns a static 403 exception and I'd like to change that to a custom view from the ...
0
votes
1
answer
501
views
Laravel handle PDO Exception message
I'm working on handling exceptions in my Laravel project.
I'm handling them in the Handler like this:
public function render($request, Exception $exception)
{
if ($exception instanceof \...
0
votes
1
answer
617
views
Handle exceptions in laravel without type-checking exceptions in the exception handler's render method and without defining custom exception?
I'm handling laravel exceptions such as NotFoundHttpException and UnauthorizedException by type-checking exceptions in the exception handler's render method, making a lot of instanceof checks which ...
0
votes
2
answers
5k
views
What triggers the "Trying to get property of non-object" error
Since I started with my first Laravel project I've been having the error
Trying to get property 'column_name' of non-object nonstop, and most of the time I've been able to fix it one way or another, ...
5
votes
3
answers
5k
views
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 correctly.
....
2
votes
3
answers
205
views
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@...
2
votes
3
answers
18k
views
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 ...
1
vote
2
answers
2k
views
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/...
0
votes
3
answers
7k
views
Laravel try catch not working, cant catch exception from a package
I am using a package https://github.com/barbushin/php-imap to read email from mail server, I have the following code
$folder = Storage::disk('local')->getAdapter()->getPathPrefix();
try {
$...
0
votes
1
answer
857
views
UnexpectedValueException laravel :protocol error
I am doing a project in Laravel 5.6 homestead. I got this error after i ran php artisan cache:config, the command ran successfully but after I ran this command and refreshed the url in my browser, I ...
0
votes
2
answers
1k
views
Laravel 5.5. App facade is not working in the Exception handler
I have such a simplified version of a class
class Handler extends ExceptionHandler
{
protected $dontReport = [];
public function report(Exception $exception)
{
$environment = \...
2
votes
1
answer
8k
views
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 ...
4
votes
2
answers
12k
views
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".
...
0
votes
3
answers
975
views
How to handle native exception in Laravel?
For example, I use:
return User::findOrFail($id);
When row does not exist with $id I get exception.
How I can return this exception in Json response? It returns HTML Laravel page now.
I need ...