mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 05:40:50 +01:00
#42: Return error in b64linebreaker.go when no out is set
This commit is contained in:
parent
3eb4bc9c52
commit
910248d999
1 changed files with 5 additions and 0 deletions
|
@ -5,9 +5,13 @@
|
||||||
package mail
|
package mail
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ErrNoOutWriter is an error message that should be used if a Base64LineBreaker has no out io.Writer set
|
||||||
|
const ErrNoOutWriter = "no io.Writer set for Base64LineBreaker"
|
||||||
|
|
||||||
// Base64LineBreaker is a io.WriteCloser that writes Base64 encoded data streams
|
// Base64LineBreaker is a io.WriteCloser that writes Base64 encoded data streams
|
||||||
// with line breaks at a given line length
|
// with line breaks at a given line length
|
||||||
type Base64LineBreaker struct {
|
type Base64LineBreaker struct {
|
||||||
|
@ -22,6 +26,7 @@ var nl = []byte(SingleNewLine)
|
||||||
// line length is reached
|
// line length is reached
|
||||||
func (l *Base64LineBreaker) Write(b []byte) (n int, err error) {
|
func (l *Base64LineBreaker) Write(b []byte) (n int, err error) {
|
||||||
if l.out == nil {
|
if l.out == nil {
|
||||||
|
err = fmt.Errorf(ErrNoOutWriter)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if l.used+len(b) < MaxBodyLength {
|
if l.used+len(b) < MaxBodyLength {
|
||||||
|
|
Loading…
Reference in a new issue