Laravel and PHP Try-Catch: Exceptions VS Errors?

preview_player
Показать описание
Try-catch is a typical PHP/Laravel way to process the exceptions. But how do you handle PHP errors? Or, do you? Let me show you a few examples.

Related links:

- - - - -
Support the channel by checking out our products:
Рекомендации по теме
Комментарии
Автор

I think it is worth mentioning that if you really want to catch any Exception or Error, you can catch Throwable, as both Errors and Exceptions do implement it.

vitorfontoura
Автор

Hi thanks for the channel.
In some rare cases, I catch \Throwable which is an interface that includes Exception and Error I think.

Kinbi
Автор

Thanks for all you do sir
from Nigeria

emekatimothyiloba
Автор

Thank for the video. I never thought of catching the error but after this video I had to say small videos like this one can actually help us all to learn new thing.
I really appreciate your efforts.

imranorthocare
Автор

Thanks a lot of, Polivas!! I didn't use /Error. I Think it is good to use it for logging. Or for API, to have a convenient message for front-end

Realteksuper
Автор

thanks a million! it's very useful for me! Your english is very clear)

nina_knyazeva
Автор

Very useful 😀
Error Handling is one of the most important things for UX

Towzlie
Автор

You have 2 inserts inside Try. It might be a good idea to do transaction & rollback to make error handling complete?

nejuspesnejsi
Автор

I always recommend caution with the DivideByZero error - sometimes it won't work as you expect! PHP being a bit crackpot at times treats straight-up division by zero as a warning rather than an error, and this can't be caught. To remedy this, always check your inputs before attempting any division.

martinh
Автор

What if we use Throwable which catches both General Exception and Errors?

kickass
Автор

Can you please make a video of php arrow function using in laravel

saifudpopz
Автор

Hi Povilas, thanks for videos. Do you have a plan for making a video about Pest testing?

zafarbekbadalboyev
Автор

Thank you for your videos and ideas, Povilas! Watching you almost every day. But I got a bit curious and started to wonder, why use 'App\Model\Thread' instead of Thread:: class, which would significantly reduce chance of typos. Noticed this in other examples and also in Laravel in general, so this is not any expression of negativity or so, just curious

harijsg
Автор

sir what are the use case of DB::transaction...?

neerajsinghtangariya
Автор

Personally, I don't use the try catch much in php because of the sequential flow, for me it is easier to throw new Exception for error handling, on the other hand when I program in java with swing or fx I use it a lot so that the environment does not trigger graphic.

javiershaka
Автор

what is the use of DB::transaction...?

binodthakur
Автор

I have encountered that divide by 0 error a long time ago and laravel catched it in develop mode.

Stoney_Eagle
Автор

make tutorial laravel inertia reactjs. Please.

santrideveloper
Автор

dear sir, how we can check this $names[ ] array variables empty or not( when i'm uploading only one or two images) in here ?
Post::create([
'title' => $request->get('title'),

'details' => $request->get('details'),

'image1' => $names[0],
'image2' => $names[1],
'image3' => $names[2],
]);

chameeradinesh
Автор

If you have Error you bad developer or you write bad testing code. Catch error is way to hide/miss problem. I see this many times when junior's catch erros and can't fix bug....

FuriousDin