2015-04-08 20:13:25 -04:00
|
|
|
/*
|
|
|
|
* Minimalist Object Storage, (C) 2015 Minio, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package drivers
|
|
|
|
|
2015-04-23 04:20:03 -04:00
|
|
|
import "fmt"
|
|
|
|
|
2015-04-08 20:13:25 -04:00
|
|
|
// BackendError - generic disk backend error
|
|
|
|
type BackendError struct {
|
|
|
|
Path string
|
|
|
|
}
|
|
|
|
|
|
|
|
// BackendCorrupted - path has corrupted data
|
|
|
|
type BackendCorrupted BackendError
|
|
|
|
|
|
|
|
// APINotImplemented - generic API not implemented error
|
|
|
|
type APINotImplemented struct {
|
|
|
|
API string
|
|
|
|
}
|
|
|
|
|
|
|
|
// GenericBucketError - generic bucket error
|
|
|
|
type GenericBucketError struct {
|
|
|
|
Bucket string
|
|
|
|
}
|
|
|
|
|
|
|
|
// GenericObjectError - generic object error
|
|
|
|
type GenericObjectError struct {
|
|
|
|
Bucket string
|
|
|
|
Object string
|
|
|
|
}
|
|
|
|
|
|
|
|
// ImplementationError - generic implementation error
|
|
|
|
type ImplementationError struct {
|
|
|
|
Bucket string
|
|
|
|
Object string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
// DigestError - Generic Md5 error
|
|
|
|
type DigestError struct {
|
|
|
|
Bucket string
|
|
|
|
Key string
|
|
|
|
Md5 string
|
|
|
|
}
|
|
|
|
|
2015-04-22 21:19:53 -04:00
|
|
|
/// ACL related errors
|
|
|
|
|
|
|
|
// InvalidACL - acl invalid
|
|
|
|
type InvalidACL struct {
|
|
|
|
ACL string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e InvalidACL) Error() string {
|
|
|
|
return "Requested ACL is " + e.ACL + " invalid"
|
|
|
|
}
|
|
|
|
|
2015-04-08 20:13:25 -04:00
|
|
|
/// Bucket related errors
|
|
|
|
|
|
|
|
// BucketNameInvalid - bucketname provided is invalid
|
|
|
|
type BucketNameInvalid GenericBucketError
|
|
|
|
|
|
|
|
// BucketExists - bucket already exists
|
|
|
|
type BucketExists GenericBucketError
|
|
|
|
|
|
|
|
// BucketNotFound - requested bucket not found
|
|
|
|
type BucketNotFound GenericBucketError
|
|
|
|
|
2015-04-27 00:15:43 -04:00
|
|
|
// TooManyBuckets - total buckets exceeded
|
|
|
|
type TooManyBuckets GenericBucketError
|
|
|
|
|
2015-04-08 20:13:25 -04:00
|
|
|
/// Object related errors
|
|
|
|
|
|
|
|
// ObjectNotFound - requested object not found
|
|
|
|
type ObjectNotFound GenericObjectError
|
|
|
|
|
|
|
|
// ObjectExists - object already exists
|
|
|
|
type ObjectExists GenericObjectError
|
|
|
|
|
2015-04-24 18:19:29 -04:00
|
|
|
// EntityTooLarge - object size exceeds maximum limit
|
|
|
|
type EntityTooLarge struct {
|
|
|
|
GenericObjectError
|
2015-05-04 02:16:10 -04:00
|
|
|
Size string
|
|
|
|
MaxSize string
|
2015-04-24 18:19:29 -04:00
|
|
|
}
|
|
|
|
|
2015-04-08 20:13:25 -04:00
|
|
|
// ObjectNameInvalid - object name provided is invalid
|
|
|
|
type ObjectNameInvalid GenericObjectError
|
|
|
|
|
|
|
|
// BadDigest - md5 mismatch from data received
|
|
|
|
type BadDigest DigestError
|
|
|
|
|
|
|
|
// InvalidDigest - md5 in request header invalid
|
|
|
|
type InvalidDigest DigestError
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e ImplementationError) Error() string {
|
|
|
|
error := ""
|
|
|
|
if e.Bucket != "" {
|
|
|
|
error = error + "Bucket: " + e.Bucket + " "
|
|
|
|
}
|
|
|
|
if e.Object != "" {
|
|
|
|
error = error + "Object: " + e.Object + " "
|
|
|
|
}
|
|
|
|
error = error + "Error: " + e.Err.Error()
|
|
|
|
return error
|
|
|
|
}
|
|
|
|
|
|
|
|
// EmbedError - wrapper function for error object
|
|
|
|
func EmbedError(bucket, object string, err error) ImplementationError {
|
|
|
|
return ImplementationError{
|
|
|
|
Bucket: bucket,
|
|
|
|
Object: object,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e ObjectNotFound) Error() string {
|
|
|
|
return "Object not Found: " + e.Bucket + "#" + e.Object
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e APINotImplemented) Error() string {
|
|
|
|
return "Api not implemented: " + e.API
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e ObjectExists) Error() string {
|
|
|
|
return "Object exists: " + e.Bucket + "#" + e.Object
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e BucketNameInvalid) Error() string {
|
|
|
|
return "Bucket name invalid: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e BucketExists) Error() string {
|
|
|
|
return "Bucket exists: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
2015-04-27 00:15:43 -04:00
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e TooManyBuckets) Error() string {
|
|
|
|
return "Bucket limit exceeded beyond 100, cannot create bucket: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
2015-04-08 20:13:25 -04:00
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e BucketNotFound) Error() string {
|
|
|
|
return "Bucket not Found: " + e.Bucket
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e ObjectNameInvalid) Error() string {
|
|
|
|
return "Object name invalid: " + e.Bucket + "#" + e.Object
|
|
|
|
}
|
|
|
|
|
2015-04-24 18:19:29 -04:00
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e EntityTooLarge) Error() string {
|
2015-05-04 02:16:10 -04:00
|
|
|
return e.Bucket + "#" + e.Object + "with " + e.Size + "reached maximum allowed size limit " + e.MaxSize
|
2015-04-24 18:19:29 -04:00
|
|
|
}
|
|
|
|
|
2015-04-08 20:13:25 -04:00
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e BackendCorrupted) Error() string {
|
|
|
|
return "Backend corrupted: " + e.Path
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e BadDigest) Error() string {
|
|
|
|
return "Md5 provided " + e.Md5 + " mismatches for: " + e.Bucket + "#" + e.Key
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
|
|
|
func (e InvalidDigest) Error() string {
|
|
|
|
return "Md5 provided " + e.Md5 + " is invalid"
|
|
|
|
}
|
2015-04-23 04:20:03 -04:00
|
|
|
|
|
|
|
// OperationNotPermitted - operation not permitted
|
|
|
|
type OperationNotPermitted struct {
|
|
|
|
Op string
|
|
|
|
Reason string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e OperationNotPermitted) Error() string {
|
|
|
|
return "Operation " + e.Op + " not permitted for reason: " + e.Reason
|
|
|
|
}
|
|
|
|
|
|
|
|
// InvalidRange - invalid range
|
|
|
|
type InvalidRange struct {
|
|
|
|
Start int64
|
|
|
|
Length int64
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e InvalidRange) Error() string {
|
|
|
|
return fmt.Sprintf("Invalid range start:%d length:%d", e.Start, e.Length)
|
|
|
|
}
|
2015-05-08 05:02:51 -04:00
|
|
|
|
|
|
|
/// Multipart related errors
|
|
|
|
|
|
|
|
// InvalidUploadID invalid upload id
|
|
|
|
type InvalidUploadID struct {
|
|
|
|
UploadID string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e InvalidUploadID) Error() string {
|
|
|
|
return "Invalid upload id " + e.UploadID
|
|
|
|
}
|