rfc7807

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ContentType = "application/problem+json"
)

Variables

View Source
var (
	GenericBootstrapCatalogFailure = newProblemID(
		path.Join(errorEndpointsPrefix, "internal-bootstrap-catalog-failure"),
		"Internal error while bootstraping the catalog",
		http.StatusInternalServerError,
	)
	CommunalStorageNotEmpty = newProblemID(
		path.Join(errorEndpointsPrefix, "communal-storage-not-empty"),
		"Communal storage is not empty",
		http.StatusInternalServerError,
	)
	CommunalStoragePathInvalid = newProblemID(
		path.Join(errorEndpointsPrefix, "communal-storage-path-invalid"),
		"Communal storage is not a valid path for the file system",
		http.StatusInternalServerError,
	)
	CommunalRWAccessError = newProblemID(
		path.Join(errorEndpointsPrefix, "communal-read-write-access-error"),
		"Failed while testing read/write access to the communal storage",
		http.StatusInternalServerError,
	)
	CommunalAccessError = newProblemID(
		path.Join(errorEndpointsPrefix, "communal-access-error"),
		"Error accessing communal storage",
		http.StatusInternalServerError,
	)
	GenericLicenseCheckFailure = newProblemID(
		path.Join(errorEndpointsPrefix, "internal-license-check-failure"),
		"Internal error while checking license file",
		http.StatusInternalServerError,
	)
	WrongRequestMethod = newProblemID(
		path.Join(errorEndpointsPrefix, "wrong-request-method"),
		"Wrong request method used",
		http.StatusMethodNotAllowed,
	)
	BadRequest = newProblemID(
		path.Join(errorEndpointsPrefix, "bad-request"),
		"Bad request sent",
		http.StatusBadRequest,
	)
	GenericHTTPInternalServerError = newProblemID(
		path.Join(errorEndpointsPrefix, "http-internal-server-error"),
		"Internal server error",
		http.StatusInternalServerError,
	)
	GenericGetNodeInfoFailure = newProblemID(
		path.Join(errorEndpointsPrefix, "internal-get-node-info-failure"),
		"Internal error while getting node information",
		http.StatusInternalServerError,
	)
	GenericLoadRemoteCatalogFailure = newProblemID(
		path.Join(errorEndpointsPrefix, "internal-load-remote-catalog-failure"),
		"Internal error while loading remote catalog",
		http.StatusInternalServerError,
	)
	GenericSpreadSecurityPersistenceFailure = newProblemID(
		path.Join(errorEndpointsPrefix, "spread-security-persistence-failure"),
		"Internal error while persisting spread encryption key",
		http.StatusInternalServerError,
	)
	GenericShowRestorePointsFailure = newProblemID(
		path.Join(errorEndpointsPrefix, "internal-show-restore-points-failure"),
		"Internal error while showing restore points",
		http.StatusInternalServerError,
	)
	SubclusterNotFound = newProblemID(
		path.Join(errorEndpointsPrefix, "subcluster-not-found"),
		"Subcluster is not found",
		http.StatusInternalServerError,
	)
	GenericCatalogEditorFailure = newProblemID(
		path.Join(errorEndpointsPrefix, "internal-catalog-editor-failure"),
		"Internal error while running catalog editor",
		http.StatusInternalServerError,
	)
	GenericVerticaDownloadFileFailure = newProblemID(
		path.Join(errorEndpointsPrefix, "general-vertica-download-file-failure"),
		"General error while running Vertica download file",
		http.StatusInternalServerError,
	)
	InsufficientPrivilege = newProblemID(
		path.Join(errorEndpointsPrefix, "insufficient-privilege"),
		"Insufficient privilege",
		http.StatusInternalServerError,
	)
	UndefinedFile = newProblemID(
		path.Join(errorEndpointsPrefix, "undefined-file"),
		"Undefined file",
		http.StatusInternalServerError,
	)
	DuplicateFile = newProblemID(
		path.Join(errorEndpointsPrefix, "duplicate-file"),
		"Duplicate file",
		http.StatusInternalServerError,
	)
	WrongObjectType = newProblemID(
		path.Join(errorEndpointsPrefix, "wrong-object-type"),
		"Wrong object type",
		http.StatusInternalServerError,
	)
	DiskFull = newProblemID(
		path.Join(errorEndpointsPrefix, "disk-full"),
		"Disk full",
		http.StatusInternalServerError,
	)
	InsufficientResources = newProblemID(
		path.Join(errorEndpointsPrefix, "insufficient-resources"),
		"Insufficient resources",
		http.StatusInternalServerError,
	)
	IOError = newProblemID(
		path.Join(errorEndpointsPrefix, "io-error"),
		"IO error",
		http.StatusInternalServerError,
	)
	QueryCanceled = newProblemID(
		path.Join(errorEndpointsPrefix, "query-canceled"),
		"Query canceled",
		http.StatusInternalServerError,
	)
	InternalVerticaDownloadFileFailure = newProblemID(
		path.Join(errorEndpointsPrefix, "internal-vertica-download-file-failure"),
		"Internal error while running Vertica download file",
		http.StatusInternalServerError,
	)
	CreateDirectoryPermissionDenied = newProblemID(
		path.Join(errorEndpointsPrefix, "create-directory-permission-denied"),
		"Permission denied while creating directories",
		http.StatusInternalServerError,
	)
	CreateDirectoryExistError = newProblemID(
		path.Join(errorEndpointsPrefix, "create-directory-exist-error"),
		"Directories already exist while creating directories",
		http.StatusInternalServerError,
	)
	CreateDirectoryInvalidPath = newProblemID(
		path.Join(errorEndpointsPrefix, "create-directory-invalid-path"),
		"Found invalid directory paths while creating directories",
		http.StatusBadRequest,
	)
	CreateDirectoryParentDirectoryExists = newProblemID(
		path.Join(errorEndpointsPrefix, "create-directory-parent-directory-exists"),
		"Parent directories already exist while creating directories",
		http.StatusInternalServerError,
	)
	CreateDirectoryParentDirectoryNoWritePermission = newProblemID(
		path.Join(errorEndpointsPrefix, "create-directory-parent-directory-no-write-permission"),
		"No write permission on parent directories while creating directories",
		http.StatusInternalServerError,
	)
	CreateDirectoryNoWritePermission = newProblemID(
		path.Join(errorEndpointsPrefix, "create-directory-no-write-permission"),
		"No write permission on directories while creating directories",
		http.StatusInternalServerError,
	)
	NonAbsolutePathError = newProblemID(
		path.Join(errorEndpointsPrefix, "non-absolute-path-error"),
		"Target path is not an absolute path",
		http.StatusBadRequest,
	)
	AuthenticationError = newProblemID(
		path.Join(errorEndpointsPrefix, "unauthorized-request"),
		"Unauthorized-request",
		http.StatusUnauthorized,
	)
)

Functions

func GenerateErrorFromResponse

func GenerateErrorFromResponse(resp string) error

MakeFromResponse will generate a VProblem parsed from a response string passed in. The VProblem will flow back as an error interface. You cannot always assume a VProblem is flowed back -- there could be a problem parsing the response. Callers should always use errors.At() function to check if it is in fact a VProblem type.

Types

type Problem

type Problem interface {
	Error() string
	SendError(w http.ResponseWriter)
}

Problem is the interface to describe an HTTP API problem.

func MakeProblem

func MakeProblem(problemID ProblemID, detail string) Problem

type ProblemID

type ProblemID struct {
	// Type contains a URI that identifies the problem type. This will be a link
	// into the vertica docs that explains the error in more detail.
	Type string `json:"type"`

	// Title is a short, human-readable summary of the problem type. This should
	// not change from occurrence to occurrence of the problem, except for
	// purposes of localization.
	Title string `json:"title"`

	// Status is the HTTP status code for this occurrence of the problem.
	Status int `json:"status,omitempty"`
}

ProblemID will identify a problem. Treat this as immutable, especially once a version of the server is released with this. If a change is required, then a new ProblemID should be generated.

type VProblem

type VProblem struct {
	ProblemID

	// A human-readable explanation specific to this occurrence of the problem.
	// Include any pertinent info in here to help them resolve the problem.
	Detail string `json:"detail,omitempty"`

	// Host is the vertica host name of IP where the problem occurred.
	Host string `json:"host,omitempty"`
}

VProblem is vertica's implementation of the RFC 7807 standard.

func New

func New(id ProblemID) *VProblem

New will return a new VProblem object. Each occurrence must have the type and title, which is why those two are parameters here. The other fields in the VProblem struct can be added after this call (see the With* helpers in the VProblem struct).

func (*VProblem) Error

func (v *VProblem) Error() string

Error implement this function so that VProblem can be passed around with Go's error interface.

func (*VProblem) IsInstanceOf

func (v *VProblem) IsInstanceOf(id ProblemID) bool

IsInstanceOf returns true if the VProblem is an occurrence of the given problem ID.

func (*VProblem) SendError

func (v *VProblem) SendError(w http.ResponseWriter)

SendError will write an error response for the problem

func (*VProblem) WithDetail

func (v *VProblem) WithDetail(d string) *VProblem

WithDetail will set the detail field in the VProblem

func (*VProblem) WithHost

func (v *VProblem) WithHost(h string) *VProblem

WithHost will set the originating host in the VPrbolem. h can be a host name or IP.

Jump to

Keyboard shortcuts

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