6 "github.com/mjl-/mox/smtp"
9func xcheckf(err error, format string, args ...any) {
11 err := fmt.Errorf("%s: %w", fmt.Sprintf(format, args...), err)
12 panic(smtpError{smtp.C451LocalErr, smtp.SeSys3Other0, err.Error(), err, true, false})
16type smtpError struct {
19 errmsg string // Sent in response.
20 err error // If set, used in logging. Typically has same information as errmsg.
22 userError bool // If this is an error on the user side, which causes logging at a lower level.
25func (e smtpError) Error() string { return e.errmsg }
26func (e smtpError) Unwrap() error { return e.err }
28func xsmtpErrorf(code int, secode string, userError bool, format string, args ...any) {
29 err := fmt.Errorf(format, args...)
30 panic(smtpError{code, secode, err.Error(), err, false, userError})
33func xsmtpServerErrorf(codes codes, format string, args ...any) {
34 xsmtpErrorf(codes.code, codes.secode, false, format, args...)
37func xsmtpUserErrorf(code int, secode string, format string, args ...any) {
38 xsmtpErrorf(code, secode, true, format, args...)