JSON API Error Responses in Laravel with Httpable Exceptions
Jess Archer show a nice approach on how to use exception in the HTTP layer.
Read more [jessarcher.com]
Posts tagged with exceptions
Jess Archer show a nice approach on how to use exception in the HTTP layer.
Read more [jessarcher.com]
You can make your code more readable by moving all your exception messages to dedicated classes. We using this technique in all our projects and packages.
Join 9,500+ smart developers
Every month I share what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
In this video, which is part of the mailcoach video course, I show how I like to write my exceptions.
At the time of writing this post, we're running a contest where you can win a free mailcoach license.
At the Clarabridge Developers blog, Toon Daelman wrote a good post on how to improve your exceptions.
You've made it to this post thinking "Why do we still need to talk about Exceptions?". Well, they're used everywhere in OOP codebases, but sometimes they're used in a way that make debugging a bit difficult. Let's look at some ways to make debugging exceptions a bit more fun!
Read more [engagor.github.io]
Alain Schlesser wrote an article on how to manage exceptions in a large codebase.
I seem to constantly work on improving my habits regarding the use of exceptions. I think it is an area that I haven’t yet fully explored, and it is very difficult to find anything more than very basic explanations and tutorials online. While the consensus is to use exceptions, there is very little information on how to structure and manage them in a larger codebase. The larger and more complex your projects become, the more important it is to start with a proper structure to avoid expensive refactoring later on.
https://www.alainschlesser.com/structuring-php-exceptions/
In my opinion a good exception message in most cases contains three things:
Named constructors for exceptions are the perfect place to build up such a message. Want to learn more? Ross Tuck wrote a good blog post on the subject too.
Ross Tuck does not blog often, but when he does you probably are going to learn something useful. In his latest post he shares some techniques regarding exceptions.
Over the last couple years, I’ve started putting my Exception messages inside static methods on custom exception classes. This is hardly a new trick, Doctrine’s been doing it for the better part of a decade. Still, many folks are surprised by it, so this article explains the how and why.http://rosstuck.com/formatting-exception-messages/
Davey Shafik cleary explains the new exception hierarchy in PHP 7.
With PHP 7 errors and exceptions are undergoing major changes. For the first time, the PHP engine will start to emit exceptions instead of standard PHP errors for (previously) fatal, and catchable fatal errors. This means that we can now handle them much more gracefully with `try... catch`.http://daveyshafik.com/archives/69237-an-exceptional-change-in-php-7-0.html
Mister community explains some shiny new features of PHP7 regarding errors and exceptions.
https://www.youtube.com/watch?v=nNezpSU9toQ
I'm really glad we won't have to work with the clumsy BaseException.