Closed oschwald closed 1 year ago
If you set a body writer with SetBodyWriter and the writer fails with an error, (*Msg).WriteTo will not return an error itself.
SetBodyWriter
(*Msg).WriteTo
Run:
package main import ( "errors" "fmt" "io" "github.com/wneessen/go-mail" ) func main() { m := mail.NewMsg() m.SetBodyWriter( mail.TypeTextPlain, func(io.Writer) (int64, error) { return 0, errors.New("failed!") }, ) _, err := m.WriteTo(io.Discard) fmt.Println(err) }
The above prints out <nil>. I would expect the body writer error to cause WriteTo to return an error, resulting in the program outputting failed! or a wrapped version of it. Right now, there is no indication that an error occurred.
<nil>
WriteTo
failed!
No response
Thanks for the report. That indeed doesn't sound right. I'll have a look what's going on there.
Thanks for the quick fix on this.
Description
If you set a body writer with
SetBodyWriter
and the writer fails with an error,(*Msg).WriteTo
will not return an error itself.To Reproduce
Run:
Expected behaviour
The above prints out
<nil>
. I would expect the body writer error to causeWriteTo
to return an error, resulting in the program outputtingfailed!
or a wrapped version of it. Right now, there is no indication that an error occurred.Screenshots
No response
Attempted Fixes
No response
Additional context
No response