specerror

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package specerror implements runtime-spec-specific tooling for tracking RFC 2119 violations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewError

func NewError(code Code, err error, version string) error

NewError creates an Error referencing a spec violation. The error can be cast to an *Error for extracting structured information about the level of the violation and a reference to the violated spec condition.

A version string (for the version of the spec that was violated) must be set to get a working URL.

Types

type Code

type Code int

Code represents the spec violation, enumerating both configuration violations and runtime violations.

const (
	// NonError represents that an input is not an error
	NonError Code = iota
	// NonRFCError represents that an error is not a rfc2119 error
	NonRFCError

	// ConfigFileExistence represents the error code of 'config.json' existence test
	ConfigFileExistence
	// ArtifactsInSingleDir represents the error code of artifacts place test
	ArtifactsInSingleDir

	// SpecVersion represents the error code of specfication version test
	SpecVersion

	// RootOnNonHyperV represents the error code of root setting test on non hyper-v containers
	RootOnNonHyperV
	// RootOnHyperV represents the error code of root setting test on hyper-v containers
	RootOnHyperV
	// PathFormatOnWindows represents the error code of the path format test on Window
	PathFormatOnWindows
	// PathName represents the error code of the path name test
	PathName
	// PathExistence represents the error code of the path existence test
	PathExistence
	// ReadonlyFilesystem represents the error code of readonly test
	ReadonlyFilesystem
	// ReadonlyOnWindows represents the error code of readonly setting test on Windows
	ReadonlyOnWindows

	// DefaultFilesystems represents the error code of default filesystems test
	DefaultFilesystems

	// CreateWithID represents the error code of 'create' lifecyle test with 'id' provided
	CreateWithID
	// CreateWithUniqueID represents the error code of 'create' lifecyle test with unique 'id' provided
	CreateWithUniqueID
	// CreateNewContainer represents the error code 'create' lifecyle test that creates new container
	CreateNewContainer
)

func FindError

func FindError(err error, code Code) Code

FindError finds an error from a source error (multiple error) and returns the error code if found. If the source error is nil or empty, return NonError. If the source error is not a multiple error, return NonRFCError.

type Error

type Error struct {
	// Err holds the RFC 2119 violation.
	Err rfc2119.Error

	// Code is a matchable holds a Code
	Code Code
}

Error represents a runtime-spec violation.

func (*Error) Error

func (err *Error) Error() string

Error returns the error message with specification reference.

Source Files

  • error.go

Jump to

Keyboard shortcuts

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