On Fri, Oct 21, 2022 at 5:57 PM Andrew Harris <harris...@spu.edu> wrote:

> Comparing 'panic' and 't.Fatal', they are similar in that there's no
> notion of recovering and making further progress, they abruptly terminate
> the process. Still, a wonky thing to say is that a 't.Fatal' call is
> completely legitimate as a form of "checked"-style error handling. It will
> log what went badly rather and prevents further tests from running. This is
> a reasonable application-level behavior for testing (for non-fatal intent,
> 't.Error' is available).
>

To be clear, I'm not saying that tests shouldn't use `t.Fatal` to stop the
test when a fatal error occurs. I'm just saying that test **helpers* *shouldn't
be using it to get around having to return errors. The fact that existing
projects ARE using it this way suggests not only that tests would benefit
from a more streamlined form of error handling, but also that there are
probably many non-test APIs written in Go that would choose to allow more
concise patterns if Go supported it.

Dan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAAViQtgyV4sjdjYkYV%2BXJsHiMPT-V%2BbNL_1Z%3D_oywOXSQDvysg%40mail.gmail.com.

Reply via email to