What's the proper way to wrap errors in Go?

What's the proper way to wrap errors in Go?

Boldly Go

1 год назад

4,781 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@esra_erimez
@esra_erimez - 29.10.2023 03:59

Every Go programmer should be subscribed to this channel

Ответить
@yarvik
@yarvik - 24.02.2023 01:27

Hi Jonathan. Thanks for the explanation. New to Go. This video helped. I've learnt something (dopamine=+1). In my case I needed, not so much a traditional stack trace as, an error with a flat array of errors - bunch of parallel calls, get array of errors back (or nil, or [], not sure yet :) ). So I initially started using wrap() from pkg, but then stumbled on stack-overflow question, mentioned in the video, which led me to this video :) for some reason I thought it was important to share all this... Thanks for contributing to the world's body of knowledge and pushing the expert levels up.

Ответить
@BarnabyKeene
@BarnabyKeene - 10.11.2022 21:05

Great overview of the error fundamentals! I've recently been neck-deep in errors and wrapping for the last month or so. I made the move to completely remove pkg/errors from my codebases and construct a more simple and composable approach using curried func(error) error functions. Mostly so I can add more than just basic strings of text into errors since I make use of structured logging and properly searchable errors make a huge difference to diagnostics!

Ответить
@ernestjohnbertillsonolaffs6461
@ernestjohnbertillsonolaffs6461 - 09.11.2022 14:20

I find delving on past libraries not so useful, would have liked a discussion on As vs Is and how to do stack traces without the old lib. Also would have liked bigger font for code, more code time and less face time. Thanks for the video.

Ответить