The Secret Life of Go: Error Handling (Part 3)
The Secret Life of Go: Error Handling (Part 3) Behavioral errors, interfaces, and the retry loop #Golang #ErrorHandling #SoftwareArchitecture #BackendDev Eleanor is a senior software engineer. Ethan is her junior colleague. They work in a beautiful beaux arts library in Lower Manhattan — the kind of place where coding languages are discussed like poetry. Episode 32 Ethan was writing a background worker that synced data with a notoriously flaky external API. He had written a loop to retry the request if it failed, but the if statement was getting out of hand. "Look at this monster," Ethan said, pointing at his screen as Eleanor walked by with her tea. // Ethan's brittle retry logic response, err := externalAPI. FetchData () if err != nil { // Check every possible network failure identity if errors. Is (err, network.ErrTimeout) || errors. Is (err, network.ErrConnectionReset) || errors. Is (err, network.ErrDNSTimeout) { fmt. P...