~/devreads

#error handling

6 posts

10 Jun 2019

Dave Cheney 9 min read

This essay is a derived from my dotGo 2019 presentation about my favourite feature in Go. Many years ago Rob Pike remarked, “Numbers are just numbers, you’ll never see 0x80ULL in a .go source file”. —Rob Pike, The Go Programming Language Beyond this pithy observation lies the fascinating world of Go’s constants. Something that is […]

goprogrammingsmall ideasconstantserror handling

27 Jan 2019

Dave Cheney 5 min read

Go 2 aims to improve the overhead of error handling, but do you know what is better than an improved syntax for handling errors? Not needing to handle errors at all. Now, I’m not saying “delete your error handling code”, instead I’m suggesting changing your code so you don’t have as many errors to handle. […]

goerror handlingerrors

12 Jun 2016

Dave Cheney 5 min read

A few months ago I gave a presentation on my philosophy for error handling. In the talk I introduced a small errors package designed to support the ideas presented in the talk. This post is an update to my previous blog post which reflects the changes in the errors package as I’ve put it into service […]

goprogrammingerror handlingerrorsstacktrace

26 Apr 2016

7 Apr 2016

Dave Cheney 2 min read

This is a thought experiment about sentinel error values in Go. Sentinel errors are bad, they introduce strong source and run time coupling, but are sometimes necessary. io.EOF is one of these sentinel values. Ideally a sentinel value should behave as a constant, that is it should be immutable and fungible. The first problem is […]

goprogrammingerror handlingerrors

3 Nov 2014

Dave Cheney 2 min read

Revisiting my post about error handling and exceptions, written well before Go hit 1.0, I’m pleased that it stands the test of time. Java has comprehensively demonstrated that checked exceptions (actually having both checked and unchecked exceptions) has been a disaster for the evolution of the language. Checked exceptions have placed a suffocating yoke of backward compatibility on […]

goprogrammingerror handlingexceptions