errors

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 7 Imported by: 3

Documentation

Overview

Package errors aids error handling for dns.Msg and darvaza.org/resolver related functions

Index

Constants

View Source
const (
	// NOANSWER is the text on [net.DNSError].Err if no [dns.Msg] was returned
	NOANSWER = "no answer"
	// NODATA is the text on [net.DNSError].Err if an authoritative server
	// returned no answer
	NODATA = "NODATA"
	// NXDOMAIN is the text on [net.DNSError].Err if the server returned a
	// Name error
	NXDOMAIN = "NXDOMAIN"
	// TRUNCATED is the text on [net.DNSError].Err if the server returned a
	// truncated response
	TRUNCATED = "dns response was truncated"
	// BADREQUEST is the text on [net.DNSError].Err if the client request
	// is invalid
	BADREQUEST = "invalid dns request"
	// BADRESPONSE is the text on [net.DNSError].Err if the server response
	// in invalid
	BADRESPONSE = "invalid dns response from server"
	// NOTIMPLEMENTED is the text on [net.DNSError].Err if the requested
	// functionality isn't implemented by the server
	NOTIMPLEMENTED = "feature not implemented by the server"
)

Variables

View Source
var (
	// CANCELLED indicates the context the exchange was using was
	// cancelled.
	CANCELLED = context.Canceled.Error()
	// DEADLINEEXCEEDED indicates the deadline the exchange was given
	// has been exceeded.
	DEADLINEEXCEEDED = context.DeadlineExceeded.Error()
)

Functions

func ErrBadRequest added in v0.6.3

func ErrBadRequest() *net.DNSError

ErrBadRequest reports an invalid request from the client

func ErrBadResponse

func ErrBadResponse() *net.DNSError

ErrBadResponse reports a bad response from the server

func ErrInternalError added in v0.7.24

func ErrInternalError(name, server string) *net.DNSError

ErrInternalError reports there was a failure on our side.

func ErrNotFound

func ErrNotFound(qName string) *net.DNSError

ErrNotFound assembles a net.DNSError indicating the asked name doesn't exist.

func ErrNotImplemented

func ErrNotImplemented(name string) *net.DNSError

ErrNotImplemented reports something isn't implemented

func ErrRefused added in v0.7.24

func ErrRefused(name string) *net.DNSError

ErrRefused reports we can't answer

func ErrTimeout

func ErrTimeout(qName string, err error) *net.DNSError

ErrTimeout assembles a Timeout() error

func ErrTimeoutMessage

func ErrTimeoutMessage(qName string, msg string) *net.DNSError

ErrTimeoutMessage is a variant of ErrTimeout that uses a given message instead of wrapping an error

func ErrTypeNotFound added in v0.7.5

func ErrTypeNotFound(qName string) *net.DNSError

ErrTypeNotFound assembles a net.DNSError indicating the name exists but not the requested qType/qClass.

func ErrorAsMsg added in v0.6.3

func ErrorAsMsg(req *dns.Msg, err error) *dns.Msg

ErrorAsMsg attempts to convert a net.DNSError into a dns.Msg response

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if the given error represents a NotFound

func IsTemporary

func IsTemporary(err error) bool

IsTemporary checks if the given error could be rechecked

func IsTimeout

func IsTimeout(err error) bool

IsTimeout checks if the given error represents a Timeout

func MsgAsError

func MsgAsError(r *dns.Msg) *net.DNSError

MsgAsError validates a response and produces a matching net.DNSError if due.

func New

func New(s string) error

New creates a simple error wrapping a string

func ValidateResponse

func ValidateResponse(server string, r *dns.Msg, err error) *net.DNSError

ValidateResponse analyses a dns.Exchange response and produces a matching net.DNSError if it's an error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL