Best practice to handle error from multiple abstract level

前端 未结 2 2036
自闭症患者
自闭症患者 2020-12-06 07:01

I wondering what is the best way to handle error form multiple level abstraction in go. Every time if I must add a new level abstraction to program, I am fo

2条回答
  •  情书的邮戳
    2020-12-06 07:40

    There are various libraries that embed stack traces in Go errors. Simply create your error with one of those, and it will bubble up with the full stack context you can later inspect or log.

    One such library:

    https://github.com/go-errors/errors

    And there are a few others I forgot.

提交回复
热议问题