A podcast about web design and development.
…
continue reading
Content provided by Dominic St-Pierre. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Dominic St-Pierre or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!
Go offline with the Player FM app!
001: Error handling in Go
MP3•Episode home
Manage episode 317183431 series 3302141
Content provided by Dominic St-Pierre. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Dominic St-Pierre or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
- 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.
42 episodes
MP3•Episode home
Manage episode 317183431 series 3302141
Content provided by Dominic St-Pierre. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Dominic St-Pierre or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
- 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.
42 episodes
All episodes
×Welcome to Player FM!
Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.