thejerf / suture

Supervisor trees for Go.
MIT License
1.32k stars 74 forks source link

Suggestion: Clarify returned error documentation #51

Closed juanigsrz closed 3 years ago

juanigsrz commented 3 years ago

In the v4 version you can return errors such as ErrDoNotRestart and ErrTerminateTree to determine further actions on the status of the service. It might be something a little bit stupid, but I did not know about 1.13 error features and so I spent a little bit figuring out the best way to return these errors without writing too much workaround code.

In the end, suture/v4 uses errors.Is() to check if an error matches a target error, such as ErrDoNotRestart. So it's not exactly needed to return, for example, ErrDoNotRestart, because as long as you wrap it inside your error the supervisor will recognize it as such.

thejerf commented 3 years ago

The fixes in the commit should help. It was, technically, documented elsewhere, but it doesn't hurt to try to move it closer to the errors themselves.