blunder

package
v0.0.0-...-4017c26 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddError

func AddError(e error, errValue FsError) error

AddError is used to add FS error detail to a Go error.

NOTE: Checks whether the error value has already been set

Note that by default merry will replace the old with the new.

func AddHTTPCode

func AddHTTPCode(e error, statusCode int) error

func Details

func Details(e error) string

Details wraps merry.Details, which returns all error details including stacktrace in a string.

func Errno

func Errno(e error) int

Errno extracts errno from the error, if it was previously wrapped. Otherwise a default value is returned.

func ErrorString

func ErrorString(e error) string

func ErrorUpdate

func ErrorUpdate(e error, currentVal FsError, changeToVal FsError) error

func HTTPCode

func HTTPCode(e error) int

HTTPCode wraps merry.HTTPCode, which returns the HTTP status code. Default value is 500.

func Is

func Is(e error, theError FsError) bool

Check if an error matches a particular FsError

NOTE: Because the value of the underlying errno is used to do this check, one cannot

use this API to distinguish between FsErrors that use the same errno value.
IOW, it can't tell the difference between InvalidFileModeError/BadMountIDError/InvalidArgError,
since they all use unix.EINVAL as their underlying errno value.

func IsNot

func IsNot(e error, theError FsError) bool

Check if an error is NOT a particular FsError

func IsNotSuccess

func IsNotSuccess(e error) bool

Check if an error is NOT the success FsError

func IsSuccess

func IsSuccess(e error) bool

Check if an error is the success FsError

func Location

func Location(e error) (file string, line int)

Location returns the file and line number of the code that generated the error. Returns zero values if e has no stacktrace.

func NewError

func NewError(errValue FsError, format string, a ...interface{}) error

NewError creates a new merry/blunder.FsError-annotated error using the given format string and arguments.

func SourceLine

func SourceLine(e error) string

SourceLine returns the string representation of Location's result Returns empty stringif e has no stacktrace.

func Stacktrace

func Stacktrace(e error) string

Stacktrace wraps merry.Stacktrace, which returns error stacktrace (if set) in a string.

Types

type FsError

type FsError int

Error constants to be used in the ProxyFS namespace.

There are two groups of constants:

  • constants that correspond to linux/POSIX errnos as defined in errno.h
  • ProxyFS-specific constants for errors not covered in the errno space

The linux/POSIX-related constants should be used in cases where there is a clear mapping to these errors. Using these constants makes it easier to map errors for use by our JSON RPC functionality.

NOTE: unix.Errno is used here because they are errno constants that exist in Go-land.

This type consists of an unsigned number describing an error condition. It implements
the error interface; we need to cast it to an int to get the errno value.
const (
	// Errors that map to linux/POSIX errnos as defined in errno.h
	//
	NotPermError          FsError = FsError(int(unix.EPERM))        // Operation not permitted
	NotFoundError         FsError = FsError(int(unix.ENOENT))       // No such file or directory
	IOError               FsError = FsError(int(unix.EIO))          // I/O error
	ReadOnlyError         FsError = FsError(int(unix.EROFS))        // Read-only file system
	TooBigError           FsError = FsError(int(unix.E2BIG))        // Argument list too long
	TooManyArgsError      FsError = FsError(int(unix.E2BIG))        // Arg list too long
	BadFileError          FsError = FsError(int(unix.EBADF))        // Bad file number
	TryAgainError         FsError = FsError(int(unix.EAGAIN))       // Try again
	OutOfMemoryError      FsError = FsError(int(unix.ENOMEM))       // Out of memory
	PermDeniedError       FsError = FsError(int(unix.EACCES))       // Permission denied
	BadAddressError       FsError = FsError(int(unix.EFAULT))       // Bad address
	DevBusyError          FsError = FsError(int(unix.EBUSY))        // Device or resource busy
	FileExistsError       FsError = FsError(int(unix.EEXIST))       // File exists
	NoDeviceError         FsError = FsError(int(unix.ENODEV))       // No such device
	NotDirError           FsError = FsError(int(unix.ENOTDIR))      // Not a directory
	IsDirError            FsError = FsError(int(unix.EISDIR))       // Is a directory
	InvalidArgError       FsError = FsError(int(unix.EINVAL))       // Invalid argument
	TableOverflowError    FsError = FsError(int(unix.ENFILE))       // File table overflow
	TooManyOpenFilesError FsError = FsError(int(unix.EMFILE))       // Too many open files
	FileTooLargeError     FsError = FsError(int(unix.EFBIG))        // File too large
	NoSpaceError          FsError = FsError(int(unix.ENOSPC))       // No space left on device
	BadSeekError          FsError = FsError(int(unix.ESPIPE))       // Illegal seek
	TooManyLinksError     FsError = FsError(int(unix.EMLINK))       // Too many links
	OutOfRangeError       FsError = FsError(int(unix.ERANGE))       // Math result not representable
	NameTooLongError      FsError = FsError(int(unix.ENAMETOOLONG)) // File name too long
	NoLocksError          FsError = FsError(int(unix.ENOLCK))       // No record locks available
	NotImplementedError   FsError = FsError(int(unix.ENOSYS))       // Function not implemented
	NotEmptyError         FsError = FsError(int(unix.ENOTEMPTY))    // Directory not empty
	TooManySymlinksError  FsError = FsError(int(unix.ELOOP))        // Too many symbolic links encountered
	NotSupportedError     FsError = FsError(int(unix.ENOTSUP))      // Operation not supported
	NoDataError           FsError = FsError(int(unix.ENODATA))      // No data available
	TimedOut              FsError = FsError(int(unix.ETIMEDOUT))    // Connection Timed Out
)
const (
	NotActiveError        FsError = NotFoundError
	BadLeaseRequest       FsError = InvalidArgError
	BadMountIDError       FsError = InvalidArgError
	BadMountVolumeError   FsError = InvalidArgError
	NotFileError          FsError = IsDirError
	SegNumNotIntError     FsError = IOError
	SegNotFoundError      FsError = IOError
	SegReadError          FsError = IOError
	InodeFlushError       FsError = IOError
	BtreeDeleteError      FsError = IOError
	BtreePutError         FsError = IOError
	BtreeLenError         FsError = IOError
	FileWriteError        FsError = IOError
	GetMetadataError      FsError = IOError
	NotSymlinkError       FsError = InvalidArgError
	IsSymlinkError        FsError = InvalidArgError
	LinkDirError          FsError = NotPermError
	BadHTTPDeleteError    FsError = IOError
	BadHTTPGetError       FsError = IOError
	BadHTTPHeadError      FsError = IOError
	BadHTTPPutError       FsError = IOError
	InvalidInodeTypeError FsError = InvalidArgError
	InvalidFileModeError  FsError = InvalidArgError
	InvalidUserIDError    FsError = InvalidArgError
	InvalidGroupIDError   FsError = InvalidArgError
	StreamNotFound        FsError = NoDataError
	AccountNotModifiable  FsError = NotPermError
	OldMetaDataDifferent  FsError = TryAgainError
)

Errors that map to constants already defined above

const (
	// Errors that are internal/specific to ProxyFS
	UnpackError FsError = 1000 + iota
	PackError
	CorruptInodeError
	NotAnObjectError
)
const SuccessError FsError = 0

Success error (sounds odd, no? - perhaps this could be renamed "NotAnError"?)

func (FsError) Value

func (err FsError) Value() int

Value returns the int value for the specified FsError constant

Jump to

Keyboard shortcuts

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