mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-14 09:52:54 +01:00
Refactor error handling in Base64LineBreaker
Switched ErrNoOutWriter from a string constant to an error object for improved error handling consistency. This change enhances clarity and reduces the risk of error handling inconsistencies in the future.
This commit is contained in:
parent
2088796049
commit
946d9888d6
1 changed files with 3 additions and 3 deletions
|
@ -13,8 +13,8 @@ import (
|
|||
// in encoding processes.
|
||||
var newlineBytes = []byte(SingleNewLine)
|
||||
|
||||
// ErrNoOutWriter is the error message returned when no io.Writer is set for Base64LineBreaker.
|
||||
const ErrNoOutWriter = "no io.Writer set for Base64LineBreaker"
|
||||
// ErrNoOutWriter is the error returned when no io.Writer is set for Base64LineBreaker.
|
||||
var ErrNoOutWriter = errors.New("no io.Writer set for Base64LineBreaker")
|
||||
|
||||
// Base64LineBreaker handles base64 encoding with the insertion of new lines after a certain number
|
||||
// of characters.
|
||||
|
@ -44,7 +44,7 @@ type Base64LineBreaker struct {
|
|||
// - err: An error if one occurred during the write operation.
|
||||
func (l *Base64LineBreaker) Write(data []byte) (numBytes int, err error) {
|
||||
if l.out == nil {
|
||||
err = errors.New(ErrNoOutWriter)
|
||||
err = ErrNoOutWriter
|
||||
return
|
||||
}
|
||||
if l.used+len(data) < MaxBodyLength {
|
||||
|
|
Loading…
Reference in a new issue