2022-11-14 18:38:39 -08:00
|
|
|
// Copyright (c) 2015-2022 MinIO, Inc.
|
2021-05-10 12:56:26 -07:00
|
|
|
//
|
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
|
//
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-04-12 16:00:50 -07:00
|
|
|
|
2016-08-17 18:24:00 -07:00
|
|
|
package cmd
|
2015-04-11 20:50:39 -07:00
|
|
|
|
2020-07-28 21:19:56 +01:00
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
2015-04-11 20:50:39 -07:00
|
|
|
|
|
|
|
|
/// Collection of standard errors
|
|
|
|
|
|
|
|
|
|
// APINotImplemented - api not implemented
|
|
|
|
|
type APINotImplemented struct {
|
2015-08-12 17:00:07 -07:00
|
|
|
API string
|
|
|
|
|
APIType string
|
2015-04-11 20:50:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e APINotImplemented) Error() string {
|
2017-02-25 20:08:32 +01:00
|
|
|
return "`" + e.API + "` is not supported for `" + e.APIType + "`."
|
2015-04-11 20:50:39 -07:00
|
|
|
}
|
|
|
|
|
|
2023-03-23 21:03:04 +01:00
|
|
|
// InvalidArgument - passed argument is invalid for this operation
|
|
|
|
|
type InvalidArgument struct{}
|
|
|
|
|
|
|
|
|
|
func (e InvalidArgument) Error() string {
|
|
|
|
|
return "invalid argument"
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-16 02:30:13 -07:00
|
|
|
// GenericBucketError - generic bucket operations error
|
|
|
|
|
type GenericBucketError struct {
|
|
|
|
|
Bucket string
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-11 16:59:51 -08:00
|
|
|
// BucketDoesNotExist - bucket does not exist.
|
|
|
|
|
type BucketDoesNotExist GenericBucketError
|
|
|
|
|
|
|
|
|
|
func (e BucketDoesNotExist) Error() string {
|
2017-02-25 20:08:32 +01:00
|
|
|
return "Bucket `" + e.Bucket + "` does not exist."
|
2015-12-11 16:59:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BucketExists - bucket exists.
|
2015-06-16 02:30:13 -07:00
|
|
|
type BucketExists GenericBucketError
|
|
|
|
|
|
|
|
|
|
func (e BucketExists) Error() string {
|
2017-02-25 20:08:32 +01:00
|
|
|
return "Bucket `" + e.Bucket + "` exists."
|
2015-06-16 02:30:13 -07:00
|
|
|
}
|
|
|
|
|
|
2015-11-17 16:12:19 -08:00
|
|
|
// BucketNameEmpty - bucket name empty (http://goo.gl/wJlzDz)
|
|
|
|
|
type BucketNameEmpty struct{}
|
|
|
|
|
|
|
|
|
|
func (e BucketNameEmpty) Error() string {
|
|
|
|
|
return "Bucket name cannot be empty."
|
2015-06-16 02:30:13 -07:00
|
|
|
}
|
|
|
|
|
|
2020-03-22 20:59:49 -07:00
|
|
|
// ObjectNameEmpty - object name empty.
|
|
|
|
|
type ObjectNameEmpty struct{}
|
|
|
|
|
|
|
|
|
|
func (e ObjectNameEmpty) Error() string {
|
|
|
|
|
return "Object name cannot be empty."
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-30 18:44:01 -07:00
|
|
|
// BucketInvalid - bucket name invalid.
|
|
|
|
|
type BucketInvalid struct {
|
|
|
|
|
Bucket string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e BucketInvalid) Error() string {
|
2022-08-03 16:43:41 +01:00
|
|
|
return "Bucket name `" + e.Bucket + "` not valid."
|
2016-03-30 18:44:01 -07:00
|
|
|
}
|
|
|
|
|
|
2015-08-06 21:52:50 -07:00
|
|
|
// ObjectAlreadyExists - typed return for MethodNotAllowed
|
|
|
|
|
type ObjectAlreadyExists struct {
|
|
|
|
|
Object string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e ObjectAlreadyExists) Error() string {
|
2017-02-25 20:08:32 +01:00
|
|
|
return "Object `" + e.Object + "` already exists."
|
2015-08-06 21:52:50 -07:00
|
|
|
}
|
|
|
|
|
|
2016-07-11 00:36:16 +01:00
|
|
|
// ObjectAlreadyExistsAsDirectory - typed return for XMinioObjectExistsAsDirectory
|
|
|
|
|
type ObjectAlreadyExistsAsDirectory struct {
|
|
|
|
|
Object string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e ObjectAlreadyExistsAsDirectory) Error() string {
|
2017-02-25 20:08:32 +01:00
|
|
|
return "Object `" + e.Object + "` already exists as directory."
|
2016-07-11 00:36:16 +01:00
|
|
|
}
|
|
|
|
|
|
2016-06-23 00:28:17 -07:00
|
|
|
// ObjectOnGlacier - object is of storage class glacier.
|
|
|
|
|
type ObjectOnGlacier struct {
|
|
|
|
|
Object string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e ObjectOnGlacier) Error() string {
|
2017-02-25 20:08:32 +01:00
|
|
|
return "Object `" + e.Object + "` is on Glacier storage."
|
2016-06-23 00:28:17 -07:00
|
|
|
}
|
|
|
|
|
|
2015-11-13 00:13:11 -08:00
|
|
|
// GenericFileError - generic file error.
|
2015-06-16 02:30:13 -07:00
|
|
|
type GenericFileError struct {
|
|
|
|
|
Path string
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 19:10:16 +01:00
|
|
|
// PathNotADirectory - this path does not correspond to a directory
|
|
|
|
|
type PathNotADirectory GenericFileError
|
|
|
|
|
|
|
|
|
|
func (e PathNotADirectory) Error() string {
|
|
|
|
|
return "Requested path `" + e.Path + "` not a directory"
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-13 00:13:11 -08:00
|
|
|
// PathNotFound (ENOENT) - file not found.
|
|
|
|
|
type PathNotFound GenericFileError
|
2015-06-16 02:30:13 -07:00
|
|
|
|
2015-11-13 00:13:11 -08:00
|
|
|
func (e PathNotFound) Error() string {
|
2023-05-04 19:10:16 +01:00
|
|
|
return "Requested path `" + e.Path + "` not found"
|
2015-06-16 02:30:13 -07:00
|
|
|
}
|
|
|
|
|
|
2015-12-11 16:59:51 -08:00
|
|
|
// PathIsNotRegular (ENOTREG) - file is not a regular file.
|
|
|
|
|
type PathIsNotRegular GenericFileError
|
2015-11-30 10:57:35 -08:00
|
|
|
|
2015-12-11 16:59:51 -08:00
|
|
|
func (e PathIsNotRegular) Error() string {
|
2023-05-04 19:10:16 +01:00
|
|
|
return "Requested path `" + e.Path + "` is not a regular file."
|
2015-11-30 10:57:35 -08:00
|
|
|
}
|
|
|
|
|
|
2015-11-13 00:13:11 -08:00
|
|
|
// PathInsufficientPermission (EPERM) - permission denied.
|
|
|
|
|
type PathInsufficientPermission GenericFileError
|
|
|
|
|
|
|
|
|
|
func (e PathInsufficientPermission) Error() string {
|
2023-05-04 19:10:16 +01:00
|
|
|
return "Insufficient permissions to access this path `" + e.Path + "`"
|
2015-11-13 00:13:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BrokenSymlink (ENOTENT) - file has broken symlink.
|
2015-10-08 22:56:59 +01:00
|
|
|
type BrokenSymlink GenericFileError
|
2015-06-16 02:30:13 -07:00
|
|
|
|
2015-10-08 22:56:59 +01:00
|
|
|
func (e BrokenSymlink) Error() string {
|
2023-05-04 19:10:16 +01:00
|
|
|
return "Requested path `" + e.Path + "` has broken symlink"
|
2015-06-16 02:30:13 -07:00
|
|
|
}
|
|
|
|
|
|
2015-11-17 14:49:16 -08:00
|
|
|
// TooManyLevelsSymlink (ELOOP) - file has too many levels of symlinks.
|
2015-10-08 22:56:59 +01:00
|
|
|
type TooManyLevelsSymlink GenericFileError
|
2015-06-16 02:30:13 -07:00
|
|
|
|
2015-10-08 22:56:59 +01:00
|
|
|
func (e TooManyLevelsSymlink) Error() string {
|
2023-05-04 19:10:16 +01:00
|
|
|
return "Requested path `" + e.Path + "` has too many levels of symlinks"
|
2015-06-16 02:30:13 -07:00
|
|
|
}
|
|
|
|
|
|
2015-11-17 14:49:16 -08:00
|
|
|
// EmptyPath (EINVAL) - invalid argument.
|
2015-06-16 02:30:13 -07:00
|
|
|
type EmptyPath struct{}
|
|
|
|
|
|
|
|
|
|
func (e EmptyPath) Error() string {
|
|
|
|
|
return "Invalid path, path cannot be empty"
|
|
|
|
|
}
|
2015-11-17 14:49:16 -08:00
|
|
|
|
|
|
|
|
// ObjectMissing (EINVAL) - object key missing.
|
2020-07-28 21:19:56 +01:00
|
|
|
type ObjectMissing struct {
|
|
|
|
|
timeRef time.Time
|
|
|
|
|
}
|
2015-11-17 14:49:16 -08:00
|
|
|
|
|
|
|
|
func (e ObjectMissing) Error() string {
|
2020-07-28 21:19:56 +01:00
|
|
|
if !e.timeRef.IsZero() {
|
|
|
|
|
return "Object did not exist at `" + e.timeRef.Format(time.RFC1123) + "`"
|
|
|
|
|
}
|
2017-04-17 17:37:11 -07:00
|
|
|
return "Object does not exist"
|
2015-11-17 14:49:16 -08:00
|
|
|
}
|
2015-12-11 16:59:51 -08:00
|
|
|
|
2020-09-21 19:42:31 +01:00
|
|
|
// ObjectIsDeleteMarker - object is a delete marker as latest
|
2022-01-06 10:55:40 -08:00
|
|
|
type ObjectIsDeleteMarker struct{}
|
2020-09-21 19:42:31 +01:00
|
|
|
|
|
|
|
|
func (e ObjectIsDeleteMarker) Error() string {
|
|
|
|
|
return "Object is marked as deleted"
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-11 16:59:51 -08:00
|
|
|
// UnexpectedShortWrite - write wrote less bytes than expected.
|
|
|
|
|
type UnexpectedShortWrite struct {
|
|
|
|
|
InputSize int
|
|
|
|
|
WriteSize int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e UnexpectedShortWrite) Error() string {
|
2017-02-25 20:08:32 +01:00
|
|
|
msg := fmt.Sprintf("Wrote less data than requested. Expected `%d` bytes, but only wrote `%d` bytes.", e.InputSize, e.WriteSize)
|
2015-12-11 16:59:51 -08:00
|
|
|
return msg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UnexpectedEOF (EPIPE) - reader closed prematurely.
|
|
|
|
|
type UnexpectedEOF struct {
|
|
|
|
|
TotalSize int64
|
|
|
|
|
TotalWritten int64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e UnexpectedEOF) Error() string {
|
2017-02-25 20:08:32 +01:00
|
|
|
msg := fmt.Sprintf("Input reader closed pre-maturely. Expected `%d` bytes, but only received `%d` bytes.", e.TotalSize, e.TotalWritten)
|
2015-12-11 16:59:51 -08:00
|
|
|
return msg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UnexpectedExcessRead - reader wrote more data than requested.
|
|
|
|
|
type UnexpectedExcessRead UnexpectedEOF
|
|
|
|
|
|
|
|
|
|
func (e UnexpectedExcessRead) Error() string {
|
2017-02-25 20:08:32 +01:00
|
|
|
msg := fmt.Sprintf("Received excess data on input reader. Expected only `%d` bytes, but received `%d` bytes.", e.TotalSize, e.TotalWritten)
|
2015-12-11 16:59:51 -08:00
|
|
|
return msg
|
|
|
|
|
}
|
2017-11-30 03:21:17 -08:00
|
|
|
|
|
|
|
|
// SameFile - source and destination are same files.
|
|
|
|
|
type SameFile struct {
|
|
|
|
|
Source, Destination string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (e SameFile) Error() string {
|
|
|
|
|
return fmt.Sprintf("'%s' and '%s' are the same file", e.Source, e.Destination)
|
|
|
|
|
}
|