errors

package
v0.0.0-...-bf55f72 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPermissionDenied = NewError(403, "Permission denied. Failed to verify the URL ownership.", "PERMISSION_DENIED")
	ErrNotFound         = NewError(404, "Requested entity was not found.", "NOT_FOUND")
)

Functions

func Is

func Is(err, target error) bool

Is calls errors.Is from the std library.

Using this function prevents importing multiple packages with the same name (errors).

func ParseError

func ParseError(data []byte) error

ParseError parses the response from r and returns the Error.

func ReadError

func ReadError(r io.Reader) error

ReadError reads the response from r and returns the Error.

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Status  string `json:"status,omitempty"`
}

Error stores the error response from Google.

See: https://developers.google.com/webmaster-tools/v1/errors

func NewError

func NewError(code int, message string, status string) Error

NewError creates a new Error with the goven values.

func (Error) Error

func (e Error) Error() string

Error returns the e.Message.

func (Error) Is

func (e Error) Is(target error) bool

Is implements the errors.Is.

The Code, the Status and the Message fields must be equal.

func (Error) MarshalJSON

func (e Error) MarshalJSON() ([]byte, error)

func (Error) String

func (e Error) String() string

String implements the fmt.Stringer interface.

Returns Status if set or Message.

func (*Error) UnmarshalJSON

func (e *Error) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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