internal

package
v4.2.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package internal provides some internal utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPStatus

func HTTPStatus(err error) int

HTTPStatus returns the HTTP status code embedded in the error, or 500 (internal server error), if there was no specified status code. If err is nil, HTTPStatus returns 0.

func StatusErrorDiff

func StatusErrorDiff(wantErr string, wantStatus int, err error) string

StatusErrorDiff returns the empty string if the expected error string and status match err. Otherwise, it returns a description of the mismatch.

func StatusErrorDiffRE

func StatusErrorDiffRE(wantErrRE string, wantStatus int, err error) string

StatusErrorDiffRE returns the empty string if the expected error RE and status match err. Otherwise, it returns a description of the mismatch.

Types

type CompositeError

type CompositeError string

CompositeError represents an HTTP status, encoded in the first byte as the status - 400, plus the error message.

func (CompositeError) Error

func (c CompositeError) Error() string

func (CompositeError) HTTPStatus

func (c CompositeError) HTTPStatus() int

HTTPStatus returns c's HTTP status code.

type Error

type Error struct {
	// Status is the HTTP status code associated with this error. Normally
	// this is the actual HTTP status returned by the server, but in some cases
	// it may be generated by Kivik directly.
	Status int

	// Message is the error message.
	Message string

	// Err is the originating error, if any.
	Err error
}

Error represents an error returned by Kivik.

This type definition is not guaranteed to remain stable, or even exported. When examining errors programatically, you should rely instead on the HTTPStatus() function in this package, rather than on directly observing the fields of this type.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Format

func (e *Error) Format(f fmt.State, c rune)

Format implements fmt.Formatter.

func (*Error) HTTPStatus

func (e *Error) HTTPStatus() int

HTTPStatus returns the HTTP status code associated with the error, or 500 (internal server error), if none.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap satisfies the errors wrapper interface.

Directories

Path Synopsis
Package mock provides minimal mocks for kivik driver interfaces.
Package mock provides minimal mocks for kivik driver interfaces.
Package nettest wraps [httptest.NewServer] to skip when called from GopherJS.
Package nettest wraps [httptest.NewServer] to skip when called from GopherJS.
Package registry handles driver registrations.
Package registry handles driver registrations.

Jump to

Keyboard shortcuts

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