Financial-Times/dotcom-reliability-kit

Write documentation on throwing useful errors

Closed this issue · 1 comments

From @apaleslimghost in #14 (comment):

suggestion: i would love to see more fleshed-out, semi-real-world examples of how and when you'd use each of these error classes in context. with the current examples, i could see somebody doing something like:

const response = await fetch('https://example.com')

if(!response.ok) {
	throw new HttpError({
		message: 'error fetching example.com'
		statusCode: response.statusCode
	})
}

and calling it a day, which is obviously not a very helpful error to be throwing. examples of how to use these types effectively (and what not to do!) could be really important.

I agree that we need some documentation on good practices in error handling to sit alongside this suite of tools. I'd like to tackle this as a separate piece of work once we have a few of the packages written and have started testing them in a real world application. Some of the practices we recommend will be informed by real-world examples which are more useful.

This is resolved as part of #31