Hacker News new | ask | show | jobs
by akamaozu 2171 days ago
This is exactly how I write JavaScript.

Sometimes a single operation has multiple ways of failing, each with their own ideal recovery / retry plan.

You want to catch the error, examine context (app state, error type and metadata at crash point) and determine what the best next step is.

This example linked below is from a web crawler service I run.

When an error occurs while logging in (multiple page loads and sometimes a redirect), there is a single handler to determine if retrying the login, crashing or alerting a human is the best course of action.

https://twitter.com/akamaozu/status/1193910918641532934

Ended up with a way to write code that recovers from errors in ways that I might not immediately understand but demonstrably works.

https://twitter.com/akamaozu/status/1274341510419329029