Dealing with failed jobs
– luisdalmolin.dev - submitted by Luis Dalmolin
Blog post with some practical tips on how to deal with failing and failed jobs.
Read more [luisdalmolin.dev]
Posts tagged with error handling
– luisdalmolin.dev - submitted by Luis Dalmolin
Blog post with some practical tips on how to deal with failing and failed jobs.
Read more [luisdalmolin.dev]
A few weeks ago, Jmac tweeted out an excellent idea. What if we could use try and catch in a collection chain?
Collections are the jam. Yet they leave me dreaming of more.
— Jason McCreary (@gonedark) June 1, 2020
Take this block that performs some custom validation logic by leveraging a value object constructor.
Collections definitely streamline it, but what if I could also chain the exception handling… 🔥 pic.twitter.com/4jj0uFgwWb
Meanwhile, Jmac and I did a few code pairing sessions to work on a possible implementation. We've added try and catch methods to the laravel-collection-macros package.
In this blog post, I'd like to share what you can do with these methods and how they work under the hood.
Join thousands of developers
Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.
No spam. Unsubscribe anytime. You can also follow me on X.
Marcel Pociot, our teams and me have worked hard to create Ignition, the brand new error page in Laravel 6.
Earlier this week I had the pleasure of being invited to the stream of Gary Hockin where we talked about the internals of Ignation.
Today at Laracon EU, Marcel Pociot and I unveiled Ignition, a beautiful new error page for Laravel. It is the new default error screen in Laravel 6 and you can manually install it into Laravel 5 applications. In this blog post, I'd like to tell you all about it.
Patrick Brouwers, the creator of Laravel Excel, explains how to handle failing jobs in Laravel
When designing software, don’t only think about the happy path. Write down (preferably with (unit) tests) what all the things are that could go wrong. Then design your solution to be able to recover those situations. (Wether or not automatic.) There isn’t a single solution to rule them all, some processes might need to have specific failure handling while others are fine with the default approach.
Read more [medium.com]
You can think of algebraic effects as resumeable try catch blocks ?. In a new post on his blog React dev Dan Abramov explains the concept.
Read more [overreacted.io]
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]
I love this pattern; and it works for any promise, with a bit of setup pic.twitter.com/kvsHU6zmpd
— assertchris (@assertchris) January 30, 2019
Read more [twitter.com]
Marcel Pociot recently created a Nova tool for Honeybadger. On their blog Marcel gives some interesting details on how it was created.
In the last weeks, I've been working with the team from Honeybadger on a custom resource tool to add Honeybadger error tracking output to Laravel Nova. It's a great addition to Nova and allows the developer to easily get access to error tracking information that, for example, is associated with specific users.
Read more [blog.honeybadger.io]
? Customizing the error bag on a Laravel form request is as easy as setting a property. I find this comes in handy if a template might have multiple error checks. pic.twitter.com/b0lsP5oJ6G
— Paul Redmond ?? (@paulredmond) 26 juni 2018
Read more [twitter.com]
Marina Posniak, UX writer at Spotify, shares some great tips on how to write error messages well.
To start, ask yourself if you even need the error message. Before writing anything, consider if there’s a way to redesign the experience so there’s no error at all. Is there a way to just make it work? (Really, the best error message is no error message.) But if you do need it, think carefully about the message. When things go wrong and the app “fails,” say something useful. The message should help the user solve the problem and move on.
Read more [thestyleofelements.org]
My colleague Sebastian took the time to write down the solution to a problem many artisans will come across at some point in time. I hope that in a future version of Laravel that error message will be improved so that it makes clear what the actual problem really is.
Every now and then I come across a Class log does not exist exception in Laravel. This particular exception is thrown when something goes wrong really early in the application, before the exception handler is instantiated.Whenever I come across this issue I'm stumped. Mostly it's related to an invalid configuration issue or an early service provider that throws an exception. I always forget how to debug this, so it's time to document my solution for tracking down the underlying error.
⚡️. @laravelphp rescue() helper : Catch a potential exception and return a default value #laravel 5.5.3 pic.twitter.com/Y8bRlx1gUc
— Jeff (@Jeffer_8a) September 8, 2017
Read more [twitter.com]
Freek Lijten, a developer at Schiphol, makes the case for just setting a sane default value instead of throwing an exception when invalid input entered the application.
I didn't think much of this, but I've seen a major drawback lately while working on a site that is a bit bigger than I was used to. With over half a million visitors a week and lots of scrapers, bots and other stuff visiting, these exceptions and fatal errors clog up logging quite a bit. Not to the point that we can't handle the volume, but it generates false positives in monitoring channels and it is something we do not want to act upon anyway.
http://www.freeklijten.nl/2017/01/04/Sane-defaults-over-Exceptions
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.
In a new post on his blog Thijs Feryn explains type errors and strict types, both introduced in PHP 7.
PHP 7 has a concept called Type Errors. These errors are thrown on a type mismatch when interacting with functions. They can be caught just like exceptions. I created a video that explains the situation. This blog post goes into more detail and has some code examples.
Rob Allen, an active member of the Zend Framework community, makes the case for giving some love to API errors.
It's not hard to have great error responses; you just need to care. Poor error response cause developers to give up with an API and go elsewhere, so it's a competitive advantage to get this right.Developers integrating with your API will thank you.
Frank de Jonge wrote an article on how to structure to your functions to avoid the duplication of cleanup code. Spoiler: use finally.
Cleaning up after yourself can be a tedious task. For example, closing file handlers after using them needs to be done. A programmer's life isn't all about the happy path. When things go pear-shaped you might end up duplicating cleanup code throughout your code. This is horrible, let's explore an alternative.
https://blog.frankdejonge.nl/finally-file-streams-and-deferred-execution-in-php/
That defer keyword from Go looks super nice.
Whoops is an error handler framework for PHP. It's easy to integrate into a lot of frameworks, including Laravel 5. I prefer using Whoops over the default Laravel behaviour because Whoops displays the lines of code where the error/exception occurred. The maintainer Dennis Sokolov recently released a new major version which features a new beautiful design.