I
I
ildar-meyker2021-11-18 17:07:22
Laravel
ildar-meyker, 2021-11-18 17:07:22

Do I need to check the results of executing Storage::put() or User::create(), etc.? Or in which case an exception will still be thrown?

I meet examples where the answers of methods are checked in one way or another. But more often than not, there is no verification of the fact of writing to the database or saving to disk. How right?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin B., 2021-11-18
@Kostik_1993

Do what your business logic requires

T
TheAndrey7, 2021-11-18
@TheAndrey7

When working with local resources, it is unlikely that something will break there. If it breaks, it's usually with your application.
It makes sense to wrap in try-catch working with external resources (Amazon S3, remote database, etc.) they can suddenly become unavailable in case of network problems and many other factors, pulling your entire application to the bottom.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question