errors

package
v5.0.0-...-b98a0e9 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CellsError is the parent of all errors
	CellsError = tozd.Base("cells")

	StatusInternalServerError = tozd.BaseWrap(CellsError, "internal")
	StatusForbidden           = tozd.BaseWrap(CellsError, "forbidden")
	StatusUnauthorized        = tozd.BaseWrap(CellsError, "unauthorized")
	StatusTooManyRequests     = tozd.BaseWrap(CellsError, "too many requests")
	StatusRequestTimeout      = tozd.BaseWrap(CellsError, "timeout")
	StatusBadRequest          = tozd.BaseWrap(CellsError, "bad request")
	StatusConflict            = tozd.BaseWrap(CellsError, "conflict")
	StatusPreconditionFailed  = tozd.BaseWrap(CellsError, "precondition failed")
	StatusNotImplemented      = tozd.BaseWrap(CellsError, "not implemented")
	StatusServiceUnavailable  = tozd.BaseWrap(CellsError, "service unavailable")
	StatusNotFound            = tozd.BaseWrap(CellsError, "not found")
	StatusCancelled           = tozd.BaseWrap(CellsError, "cancelled")
	StatusAborted             = tozd.BaseWrap(CellsError, "aborted")
	StatusOutOfRange          = tozd.BaseWrap(CellsError, "out of range")
	StatusDataLoss            = tozd.BaseWrap(CellsError, "data loss")
	StatusLocked              = tozd.BaseWrap(CellsError, "locked")
	StatusQuotaReached        = tozd.BaseWrap(CellsError, "quota reached")

	InvalidParameters = RegisterBaseSentinel(StatusBadRequest, "invalid parameters")

	UserNotFound       = RegisterBaseSentinel(StatusNotFound, "user not found")
	NodeNotFound       = RegisterBaseSentinel(StatusNotFound, "node not found")
	RecycleNotFound    = RegisterBaseSentinel(StatusNotFound, "recycle not found")
	KeyNotFound        = RegisterBaseSentinel(StatusNotFound, "key not found")
	BucketNotFound     = RegisterBaseSentinel(StatusNotFound, "bucket not found")
	ObjectNotFound     = RegisterBaseSentinel(StatusNotFound, "object not found")
	DatasourceNotFound = RegisterBaseSentinel(StatusNotFound, "datasource not found")
	RoleNotFound       = RegisterBaseSentinel(StatusNotFound, "role not found")
	TemplateNotFound   = RegisterBaseSentinel(StatusNotFound, "template not found")
	VersionNotFound    = RegisterBaseSentinel(StatusNotFound, "version not found")
	JobNotFound        = RegisterBaseSentinel(StatusNotFound, "job not found")
	ActionNotFound     = RegisterBaseSentinel(StatusNotFound, "action not found")
	WorkspaceNotFound  = RegisterBaseSentinel(StatusNotFound, "workspace not found")
	CellNotFound       = RegisterBaseSentinel(WorkspaceNotFound, "cell not found")
	ShareNotFound      = RegisterBaseSentinel(WorkspaceNotFound, "share not found")
	DatasourceConflict = RegisterBaseSentinel(StatusConflict, "datasource conflict")
	NodeTypeConflict   = RegisterBaseSentinel(StatusConflict, "file / folder type conflict")
	NodeIndexConflict  = RegisterBaseSentinel(StatusConflict, "index mpath conflict")

	UserLocked      = RegisterBaseSentinel(StatusUnauthorized, "user is locked")
	LoginNotAllowed = RegisterBaseSentinel(StatusUnauthorized, "login not allowed")
	LoginFailed     = RegisterBaseSentinel(StatusUnauthorized, "login failed")
	InvalidIDToken  = RegisterBaseSentinel(StatusUnauthorized, "invalid id_token")
	EmptyIDToken    = RegisterBaseSentinel(InvalidIDToken, "empty idToken")
	ExpiredIDToken  = RegisterBaseSentinel(InvalidIDToken, "expired idToken")

	AccessListNotFound        = RegisterBaseSentinel(StatusForbidden, "access list not found")
	ContextUserNotFound       = RegisterBaseSentinel(StatusForbidden, "context user not found")
	ExtensionsNotAllowed      = RegisterBaseSentinel(StatusForbidden, "extensions not allowed")
	OutOfAccessibleWorkspaces = RegisterBaseSentinel(StatusForbidden, "node does not belong to any accessible workspace")
	FileLocked                = RegisterBaseSentinel(StatusForbidden, "file locked")
	RoleACLsNotEditable       = RegisterBaseSentinel(StatusForbidden, "role ACLs not editable")
	RoleNotAssignable         = RegisterBaseSentinel(StatusForbidden, "role not assignable")
	NamespaceNotAllowed       = RegisterBaseSentinel(StatusForbidden, "namespace not allowed")

	SharePermissionsForbidden      = RegisterBaseSentinel(StatusForbidden, "share permissions not allowed")
	ShareFileCellsForbidden        = RegisterBaseSentinel(SharePermissionsForbidden, "share file as cells not allowed")
	ShareFolderCellsForbidden      = RegisterBaseSentinel(SharePermissionsForbidden, "share folder as cells not allowed")
	ShareFileLinkForbidden         = RegisterBaseSentinel(SharePermissionsForbidden, "share file as link not allowed")
	ShareFolderLinkForbidden       = RegisterBaseSentinel(SharePermissionsForbidden, "share folder as link not allowed")
	ShareCellMaxExpirationRequired = RegisterBaseSentinel(SharePermissionsForbidden, "share cell max expiration required")
	ShareLinkMaxExpirationRequired = RegisterBaseSentinel(SharePermissionsForbidden, "share link max expiration required")
	ShareLinkMaxDownloadRequired   = RegisterBaseSentinel(SharePermissionsForbidden, "share link max download required")
	ShareLinkPasswordRequired      = RegisterBaseSentinel(SharePermissionsForbidden, "share link max password required")
	ShareLinkHashNotEditable       = RegisterBaseSentinel(SharePermissionsForbidden, "hash not editable")
	ShareLinkHashMinLengthRequired = RegisterBaseSentinel(SharePermissionsForbidden, "hash min length required")
	ShareWrongType                 = RegisterBaseSentinel(SharePermissionsForbidden, "share wrong type, use workspace API")
	ShareNotEditable               = RegisterBaseSentinel(SharePermissionsForbidden, "share not editable")
	ShareLinkNotEditable           = RegisterBaseSentinel(ShareNotEditable, "you are not allowed to edit this link")
	ShareCellNotEditable           = RegisterBaseSentinel(ShareNotEditable, "you are not allowed to edit this cell")

	DAO          = RegisterBaseSentinel(StatusInternalServerError, "dao")
	ResolveError = RegisterBaseSentinel(DAO, "dao resolution failed")
	SqlDAO       = RegisterBaseSentinel(DAO, "sql")
	MongoDAO     = RegisterBaseSentinel(DAO, "mongo")
	BoltDAO      = RegisterBaseSentinel(DAO, "bolt")
	BleveDAO     = RegisterBaseSentinel(DAO, "bleve")

	PathNotReadable       = RegisterBaseSentinel(StatusForbidden, "path.not.readable")
	PathNotWriteable      = RegisterBaseSentinel(StatusForbidden, "path.not.writeable")
	PathReadonly          = RegisterBaseSentinel(StatusForbidden, "path.readonly")
	PathExplicitDeny      = RegisterBaseSentinel(StatusForbidden, "explicit.deny")
	PathDownloadForbidden = RegisterBaseSentinel(StatusForbidden, "download.forbidden")
	PathUploadForbidden   = RegisterBaseSentinel(StatusForbidden, "upload.forbidden")
	PathDeleteForbidden   = RegisterBaseSentinel(StatusForbidden, "delete.forbidden")
	CellNotEditable       = RegisterBaseSentinel(StatusForbidden, "cell not editable")

	UnmarshalError = RegisterBaseSentinel(StatusInternalServerError, "unmarshal error")

	RestInputError       = RegisterBaseSentinel(StatusBadRequest, "rest input error")
	RestOutputWriteError = RegisterBaseSentinel(StatusBadRequest, "rest output write error")

	BinaryCannotReadStore  = RegisterBaseSentinel(StatusForbidden, "cannot read store")
	BinaryCannotWriteStore = RegisterBaseSentinel(StatusForbidden, "cannot write store")
	BranchInfoMissing      = RegisterBaseSentinel(StatusInternalServerError, "branch info missing")
	BranchInfoRootMissing  = RegisterBaseSentinel(StatusInternalServerError, "branch info root missing")
	BranchInfoACLMissing   = RegisterBaseSentinel(StatusInternalServerError, "branch info ACL missing")

	ServiceError            = RegisterBaseSentinel(StatusInternalServerError, "service error")
	ServiceStartError       = RegisterBaseSentinel(ServiceError, "service start error")
	ServiceNoServerAttached = RegisterBaseSentinel(ServiceError, "no server attached")
)
View Source
var (

	// New creates an error including a stack trace
	New = tozd.New
	// Errorf creates an error including a stack trace. You can use %w to reference a known sentinel or another error.
	Errorf = tozd.Errorf

	// WithDetails appends details to an error, eventually recording a stack trace
	WithDetails = tozd.WithDetails
	// WithStack records a stack trace using a Sentinel error
	WithStack = tozd.WithStack
	// WithMessage initialize a Sentinel error with a message and records a stack trace
	WithMessage = tozd.WithMessage
	// WithMessagef initialize a Sentinel error with formatting arguments
	WithMessagef = tozd.WithMessagef
	// Details reads the map[string]interface{} details of a given error (not recursively unwrapping)
	Details = tozd.Details

	Join = tozd.Join

	// Is replaces stdlib.Is
	Is = tozd.Is
	// As replaces stdlib.As
	As = tozd.As
)

Functions

func AllDetails

func AllDetails(err error) map[string]interface{}

AllDetails stacks all Details from all unwrapped errors. It overrides tozd version to avoid stopping on Cause() case and to gather joined errors details

func ByName

func ByName(name string) error

func IsNetworkError

func IsNetworkError(err error) bool

IsNetworkError tries to detect if error is a network error.

func IsStreamFinished

func IsStreamFinished(err error) bool

func RegisterBaseSentinel

func RegisterBaseSentinel(parent error, name string) error

func Tag

func Tag(err error, sentinel error) error

Tag an existing error with a known sentinel. If it is already responding to Is(er, sentinel), it will be unmodified.

func WithAPICode

func WithAPICode(base error, code ApiCode, kv ...interface{}) error

WithAPICode adds APICode and optional formatting arguments as error Details It does not override an existing APICode

func Zap

func Zap(err error) zap.Field

Types

type ApiCode

type ApiCode string
const (
	ApiInternalServerError ApiCode = "E_INTERNAL_SERVER_ERROR"
	ApiUnauthorized        ApiCode = "E_UNAUTHORIZED"
	ApiForbidden           ApiCode = "E_FORBIDDEN"
	ApiNotFound            ApiCode = "E_NOT_FOUND"
	ApiResourceLocked      ApiCode = "E_RESOURCE_LOCKED"
	ApiServiceUnavailable  ApiCode = "E_SERVICE_UNAVAILABLE"

	ApiForbiddenEdit ApiCode = "E_FORBIDDEN_EDIT"
	ApiForbiddenRead ApiCode = "E_FORBIDDEN_READ"

	ApiLoginFailed               ApiCode = "E_LOGIN_FAILED"
	ApiUserAlreadyExists         ApiCode = "E_USER_ALREADY_EXISTS"
	ApiUserLocked                ApiCode = "E_USER_LOCKED"
	ApiUserNotEditable           ApiCode = "E_USER_NOT_EDITABLE"
	ApiUserCannotCreate          ApiCode = "E_USER_CANNOT_CREATE"
	ApiUserCannotCreateProfile   ApiCode = "E_USER_CANNOT_CREATE_PROFILE"
	ApiUserCannotDeleteOwn       ApiCode = "E_USER_CANNOT_DELETE_OWN"
	ApiUserCannotIncreaseProfile ApiCode = "E_USER_CANNOT_INCREASE_PROFILE"
	ApiGroupCannotCreate         ApiCode = "E_GROUP_CANNOT_CREATE"
	ApiGroupCannotDeleteOwn      ApiCode = "E_GROUP_CANNOT_DELETE_OWN"

	ApiWorkspaceNotFound    ApiCode = "E_WORKSPACE_NOT_FOUND"
	ApiWorkspaceNotEditable ApiCode = "E_WORKSPACE_NOT_EDITABLE"
)

func HasApiCode

func HasApiCode(err error) (code ApiCode, args []interface{}, has bool)

type E

type E tozd.E

E is an alias to original library

type Leaf

type Leaf interface {
	error
	Name() string
	Err() error
	Parent() error
}

func AsLeafs

func AsLeafs(er error) (ee []Leaf)

Directories

Path Synopsis
Package lang provides i18n strings related to activities
Package lang provides i18n strings related to activities

Jump to

Keyboard shortcuts

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