D
D
Dmitriy2020-11-09 15:17:20
Laravel
Dmitriy, 2020-11-09 15:17:20

How to display Exception text instead of 'Server Error' Laravel?

If I set APP_DEBUG=false in .env.
That instead of the text of my Exception' is produced 'Server Error'
Is BaseExceptions extends DomainExceptions.
And all the rest are inherited from BaseExceptions.
How to output the text of a specific Exception?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-11-09
@FanatPHP

To output a specific exception, you must throw it. for example

class SooperPooperException extends BaseException {}

after that it can be caught in the controller and output in a standard way.
try {
    // вызываем свой код который может кинуть исключение
} catch (SooperPooperException $e) {
   // рендерим ответ
}

But at the same time, do not catch any root exceptions, but only those that contain text for the user

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question