Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ligonsker's avatar

How to handle errors when using Storage::download()?

Hello,

How can I handle errors when using the Storage::download() method? In the docs there is not much information, other than the code to download: https://laravel.com/docs/10.x/filesystem#downloading-files

For example, when the path to a file is wrong (or maybe they file was deleted) and i attempt to download from that path, I get:

Unable to retrieve the file_size for file ...

How can I handle it and return my errors instead?

Thanks

0 likes
3 replies
Snapey's avatar

As with all errors, you can wrap in try-catch

Please or to participate in this conversation.