Log in

goodpods headphones icon

To access all our features

Open the Goodpods app
Close icon
go podcast() - 001: Error handling in Go

001: Error handling in Go

go podcast()

01/10/22 • 16 min

plus icon
bookmark
Share icon
  • Wrapping error: fmt.Errorf("error trying to do X: %w", err)
  • Package errors: https://pkg.go.dev/errors

Example of not using the happy path at 1st indentation:

try {
if (user.HasAccessTo(Admin) {
if (somethingElse()) {
// happy path
}
else {}
}
else {}
}
catch(Exception ex) {
// what really happened, and where?
}

An example of happy path in idiomatic Go:

ok, error := hasAccessTo(user, ADMIN)
if err != nil || !ok {
// handle not access
}

if !somethingElse() {
// handle something else false
}
// Happy path

My course on building SaaS apps in Go.

01/10/22 • 16 min

plus icon
bookmark
Share icon

Generate a badge

Get a badge for your website that links back to this episode

Select type & size
Open dropdown icon
share badge image

<a href="https://goodpods.com/podcasts/go-podcast-481108/001-error-handling-in-go-64380026"> <img src="https://storage.googleapis.com/goodpods-images-bucket/badges/generic-badge-1.svg" alt="listen to 001: error handling in go on goodpods" style="width: 225px" /> </a>

Copy