Use error decorators to simplify your error handling code

  Рет қаралды 5,936

Boldly Go

Boldly Go

Күн бұрын

Пікірлер: 8
@esra_erimez
@esra_erimez Жыл бұрын
The importance of your content simply cannot be overstated.
@mroobert
@mroobert Жыл бұрын
When you present the problem, the function Retry is wrong. The code has " err := do() " then " if err != nil { return nil } ". It should be "if err == nil { return nil }" because you want to stop retrying if the do() method is successful. Thx for the video!
@boldlygo
@boldlygo Жыл бұрын
Good catch. I noticed the same thing after it was too late.
@ernestjohnbertillsonolaffs6461
@ernestjohnbertillsonolaffs6461 Жыл бұрын
Technique described is very important, especially in large codebases. Example is a little contrived though.
@boldlygo
@boldlygo Жыл бұрын
I actually ran into this exact scenario twice in the last week, once with each of two clients. That's what inspired me to create the video.
@a0um
@a0um 4 ай бұрын
Why Go doesn’t have proper enum types?
@101graffhead
@101graffhead Жыл бұрын
This still requires the callback function to return fatal error itself, i thought it was going to be a completely external approach without touching the callback, of course using the pattern in video should be used when possible, but might not always be possible in case of using a 3rd party library function's whose fatal error equivalent is private and used internally by library itself which what i encountered at work, so what i did was actually going to library's source and copy its error string and just compared to it, its dirty but worked, since changing and forking the library was not really an option
@boldlygo
@boldlygo Жыл бұрын
If you're using a library that doesn't use "intelligent" errors, string comparison may indeed be the only option. Fortunately, it's rarely the only option, as I discuss in this other video: kzbin.info/www/bejne/i5uwn3SOfruKgMk
err != nil Is GOOD? (And Why)
7:19
ThePrimeTime
Рет қаралды 97 М.
PLEASE Use These 5 Python Decorators
20:12
Tech With Tim
Рет қаралды 122 М.
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 5 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 56 МЛН
How To Choose Mac N Cheese Date Night.. 🧀
00:58
Jojo Sim
Рет қаралды 86 МЛН
Exception vs Errors | Chris Lattner and Lex Fridman
8:02
Lex Clips
Рет қаралды 49 М.
5 Levels of Go Error Handling
19:13
RageCageCodes
Рет қаралды 14 М.
Function Iterators might just change the way we write loops in Go
11:35
All about the Go errors package
16:14
Boldly Go
Рет қаралды 2,9 М.
Golang Error Handling Is Better Than You Think!
18:53
Anthony GG
Рет қаралды 28 М.
When RESTful architecture isn't enough...
21:02
Dreams of Code
Рет қаралды 283 М.
Go's Naked Returns: Be afraid!
15:11
Boldly Go
Рет қаралды 964
5 Useful Python Decorators (ft. Carberra)
14:34
Indently
Рет қаралды 106 М.
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 5 МЛН