You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
164 lines
4.2 KiB
164 lines
4.2 KiB
10 years ago
|
/*
|
||
10 years ago
|
* Minimalist Object Storage, (C) 2015 Minio, Inc.
|
||
10 years ago
|
*
|
||
|
* 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.
|
||
|
*/
|
||
|
|
||
10 years ago
|
package drivers
|
||
10 years ago
|
|
||
10 years ago
|
// BackendError - generic disk backend error
|
||
10 years ago
|
type BackendError struct {
|
||
|
Path string
|
||
|
}
|
||
|
|
||
10 years ago
|
// BackendCorrupted - path has corrupted data
|
||
|
type BackendCorrupted BackendError
|
||
10 years ago
|
|
||
10 years ago
|
// APINotImplemented - generic API not implemented error
|
||
|
type APINotImplemented struct {
|
||
|
API string
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
// GenericBucketError - generic bucket error
|
||
10 years ago
|
type GenericBucketError struct {
|
||
10 years ago
|
Bucket string
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
// GenericObjectError - generic object error
|
||
10 years ago
|
type GenericObjectError struct {
|
||
|
Bucket string
|
||
|
Object string
|
||
|
}
|
||
|
|
||
10 years ago
|
// ImplementationError - generic implementation error
|
||
10 years ago
|
type ImplementationError struct {
|
||
|
Bucket string
|
||
|
Object string
|
||
|
Err error
|
||
|
}
|
||
|
|
||
10 years ago
|
// DigestError - Generic Md5 error
|
||
|
type DigestError struct {
|
||
|
Bucket string
|
||
|
Key string
|
||
|
Md5 string
|
||
|
}
|
||
|
|
||
10 years ago
|
/// Bucket related errors
|
||
|
|
||
|
// BucketPolicyNotFound - missing bucket policy
|
||
10 years ago
|
type BucketPolicyNotFound GenericBucketError
|
||
10 years ago
|
|
||
|
// BucketNameInvalid - bucketname provided is invalid
|
||
10 years ago
|
type BucketNameInvalid GenericBucketError
|
||
10 years ago
|
|
||
|
// BucketExists - bucket already exists
|
||
10 years ago
|
type BucketExists GenericBucketError
|
||
10 years ago
|
|
||
|
// BucketNotFound - requested bucket not found
|
||
10 years ago
|
type BucketNotFound GenericBucketError
|
||
10 years ago
|
|
||
|
/// Object related errors
|
||
|
|
||
|
// ObjectNotFound - requested object not found
|
||
|
type ObjectNotFound GenericObjectError
|
||
|
|
||
|
// ObjectExists - object already exists
|
||
|
type ObjectExists GenericObjectError
|
||
|
|
||
|
// ObjectNameInvalid - object name provided is invalid
|
||
10 years ago
|
type ObjectNameInvalid GenericObjectError
|
||
|
|
||
10 years ago
|
// BadDigest - md5 mismatch from data received
|
||
|
type BadDigest DigestError
|
||
|
|
||
|
// InvalidDigest - md5 in request header invalid
|
||
|
type InvalidDigest DigestError
|
||
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e ImplementationError) Error() string {
|
||
10 years ago
|
error := ""
|
||
10 years ago
|
if e.Bucket != "" {
|
||
|
error = error + "Bucket: " + e.Bucket + " "
|
||
10 years ago
|
}
|
||
10 years ago
|
if e.Object != "" {
|
||
|
error = error + "Object: " + e.Object + " "
|
||
10 years ago
|
}
|
||
10 years ago
|
error = error + "Error: " + e.Err.Error()
|
||
10 years ago
|
return error
|
||
|
}
|
||
|
|
||
10 years ago
|
// EmbedError - wrapper function for error object
|
||
10 years ago
|
func EmbedError(bucket, object string, err error) ImplementationError {
|
||
|
return ImplementationError{
|
||
|
Bucket: bucket,
|
||
|
Object: object,
|
||
|
Err: err,
|
||
|
}
|
||
|
}
|
||
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e BucketPolicyNotFound) Error() string {
|
||
|
return "Bucket policy not found for: " + e.Bucket
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e ObjectNotFound) Error() string {
|
||
|
return "Object not Found: " + e.Bucket + "#" + e.Object
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e APINotImplemented) Error() string {
|
||
10 years ago
|
return "Api not implemented: " + e.API
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e ObjectExists) Error() string {
|
||
|
return "Object exists: " + e.Bucket + "#" + e.Object
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e BucketNameInvalid) Error() string {
|
||
|
return "Bucket name invalid: " + e.Bucket
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e BucketExists) Error() string {
|
||
|
return "Bucket exists: " + e.Bucket
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e BucketNotFound) Error() string {
|
||
|
return "Bucket not Found: " + e.Bucket
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e ObjectNameInvalid) Error() string {
|
||
|
return "Object name invalid: " + e.Bucket + "#" + e.Object
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
// Return string an error formatted as the given text
|
||
10 years ago
|
func (e BackendCorrupted) Error() string {
|
||
|
return "Backend corrupted: " + e.Path
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
|
// 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"
|
||
|
}
|