 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package errors defines error-handling and primitives used across maddy, notably to pass additional error information across module boundaries.
Index ¶
- func Fields(err error) map[string]interface{}
- func IsTemporary(err error) bool
- func IsTemporaryOrUnspec(err error) bool
- func SMTPCode(err error, temporaryCode, permanentCode int) int
- func UnwrapDNSErr(err error) (reason string, misc map[string]interface{})
- func WithFields(err error, fields map[string]interface{}) error
- func WithTemporary(err error, temporary bool) error
- type EnhancedCode
- type SMTPError
- type TemporaryErr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTemporary ¶
IsTemporary returns true whether the passed error object have a Temporary() method and it returns true.
func IsTemporaryOrUnspec ¶
IsTemporaryOrUnspec is similar to IsTemporary except that it returns true if error does not have a Temporary() method. Basically, it assumes that errors are temporary by default compared to IsTemporary that assumes errors are permanent by default.
func SMTPCode ¶
SMTPCode is a convenience function that returns one of its arguments depending on the result of exterrors.IsTemporary for the specified error object.
func UnwrapDNSErr ¶
func WithFields ¶
func WithTemporary ¶
WithTemporary wraps the passed error object with the implementation of the Temporary() method that will return the specified value.
Original error value can be obtained using errors.Unwrap.
Types ¶
type EnhancedCode ¶
type EnhancedCode smtp.EnhancedCode
func SMTPEnchCode ¶
func SMTPEnchCode(err error, code EnhancedCode) EnhancedCode
SMTPEnchCode is a convenience function changes the first number of the SMTP enhanced status code based on the value exterrors.IsTemporary returns for the specified error object.
func (EnhancedCode) FormatLog ¶
func (ec EnhancedCode) FormatLog() string
type SMTPError ¶
type SMTPError struct {
	// SMTP status code. Most of these codes are overly generic and are barely
	// useful. Nonetheless, take a look at the 'Associated basic status code'
	// in the SMTP Enhanced Status Codes registry (below), then check RFC 5321
	// (Section 4.3.2) and pick what you like. Stick to 451 and 554 if there are
	// no useful codes.
	Code int
	// Enhanced SMTP status code. If you are unsure, take a look at
	// https://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xhtml
	EnhancedCode EnhancedCode
	// Error message that should be returned to the SMTP client.
	// Usually, it should be a short and generic description of the error
	// that excludes any details. Especially, for checks, avoid
	// mentioning the exact policy mechanism used to avoid disclosing the
	// server configuration details. Don't say "DNS error during DMARC check",
	// say "DNS error during policy check". Same goes for network and file I/O
	// errors. ESPECIALLY, don't include any configuration variables or object
	// identifiers in it.
	Message string
	// If the error was generated by a message check
	// this field includes module name.
	CheckName string
	// If the error was generated by a delivery target
	// this field includes module name.
	TargetName string
	// If the error was generated by a message modifier
	// this field includes module name.
	ModifierName string
	// If the error was generated as a result of another
	// error - this field contains the original error object.
	//
	// Err.Error() will be copied into the 'reason' field returned
	// by the Fields method unless a different values is specified
	// using the Reason field below.
	Err error
	// Textual explanation of the actual error reason. Defaults to the
	// Err.Error() value if Err is not nil, empty string otherwise.
	Reason string
	Misc map[string]interface{}
}
    SMTPError type is a copy of emersion/go-smtp.SMTPError type that extends it with Fields method for logging and reporting in maddy. It should be used instead of the go-smtp library type for all errors.
type TemporaryErr ¶
type TemporaryErr interface {
	Temporary() bool
}