2015-02-08 05:54:21 -05:00
|
|
|
/*
|
|
|
|
* Mini 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.
|
|
|
|
*/
|
|
|
|
|
2015-01-21 02:16:06 -05:00
|
|
|
package storage
|
|
|
|
|
2015-03-05 23:32:04 -05:00
|
|
|
// BackendError - generic disk backend error
|
2015-01-27 21:43:55 -05:00
|
|
|
type BackendError struct {
|
|
|
|
Path string
|
|
|
|
}
|
|
|
|
|
2015-03-05 23:32:04 -05:00
|
|
|
// BackendCorrupted - path has corrupted data
|
|
|
|
type BackendCorrupted BackendError
|
2015-01-21 02:16:06 -05:00
|
|
|
|
2015-03-05 23:32:04 -05:00
|
|
|
// APINotImplemented - generic API not implemented error
|
|
|
|
type APINotImplemented struct {
|
|
|
|
API string
|
2015-02-15 20:03:27 -05:00
|
|
|
}
|
|
|
|
|
2015-03-05 23:32:04 -05:00
|
|
|
// GenericBucketError - generic bucket error
|
2015-01-24 18:35:01 -05:00
|
|
|
type GenericBucketError struct {
|
2015-01-21 15:44:09 -05:00
|
|
|
Bucket string
|
2015-01-21 03:50:23 -05:00
|
|
|
}
|
|
|
|
|
2015-03-05 23:32:04 -05:00
|
|
|
// GenericObjectError - generic object error
|
2015-01-25 20:41:59 -05:00
|
|
|
type GenericObjectError struct {
|
|
|
|
Bucket string
|
|
|
|
Object string
|
|
|
|
}
|
|
|
|
|
2015-03-05 23:32:04 -05:00
|
|
|
// ImplementationError - generic implementation error
|
2015-01-25 20:41:59 -05:00
|
|
|
type ImplementationError struct {
|
|
|
|
Bucket string
|
|
|
|
Object string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
2015-03-05 23:32:04 -05:00
|
|
|
/// Bucket related errors
|
|
|
|
|
|
|
|
// BucketPolicyNotFound - missing bucket policy
|
2015-03-03 05:36:12 -05:00
|
|
|
type BucketPolicyNotFound GenericBucketError
|
2015-03-05 23:32:04 -05:00
|
|
|
|
|
|
|
// BucketNameInvalid - bucketname provided is invalid
|
2015-03-03 05:36:12 -05:00
|
|
|
type BucketNameInvalid GenericBucketError
|
2015-03-05 23:32:04 -05:00
|
|
|
|
|
|
|
// BucketExists - bucket already exists
|
2015-03-03 05:36:12 -05:00
|
|
|
type BucketExists GenericBucketError
|
2015-03-05 23:32:04 -05:00
|
|
|
|
|
|
|
// BucketNotFound - requested bucket not found
|
2015-03-03 05:36:12 -05:00
|
|
|
type BucketNotFound GenericBucketError
|
2015-03-05 23:32:04 -05:00
|
|
|
|
|
|
|
/// Object related errors
|
|
|
|
|
|
|
|
// ObjectNotFound - requested object not found
|
|
|
|
type ObjectNotFound GenericObjectError
|
|
|
|
|
|
|
|
// ObjectExists - object already exists
|
|
|
|
type ObjectExists GenericObjectError
|
|
|
|
|
|
|
|
// ObjectNameInvalid - object name provided is invalid
|
2015-03-03 05:36:12 -05:00
|
|
|
type ObjectNameInvalid GenericObjectError
|
|
|
|
|
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e ImplementationError) Error() string {
|
2015-01-25 20:41:59 -05:00
|
|
|
error := ""
|
2015-03-05 23:32:04 -05:00
|
|
|
if e.Bucket != "" {
|
|
|
|
error = error + "Bucket: " + e.Bucket + " "
|
2015-01-25 20:41:59 -05:00
|
|
|
}
|
2015-03-05 23:32:04 -05:00
|
|
|
if e.Object != "" {
|
|
|
|
error = error + "Object: " + e.Object + " "
|
2015-01-25 20:41:59 -05:00
|
|
|
}
|
2015-03-05 23:32:04 -05:00
|
|
|
error = error + "Error: " + e.Err.Error()
|
2015-01-25 20:41:59 -05:00
|
|
|
return error
|
|
|
|
}
|
|
|
|
|
2015-03-05 23:32:04 -05:00
|
|
|
// EmbedError - wrapper function for error object
|
2015-01-25 20:41:59 -05:00
|
|
|
func EmbedError(bucket, object string, err error) ImplementationError {
|
|
|
|
return ImplementationError{
|
|
|
|
Bucket: bucket,
|
|
|
|
Object: object,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-03 05:36:12 -05:00
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e BucketPolicyNotFound) Error() string {
|
|
|
|
return "Bucket policy not found for: " + e.Bucket
|
2015-02-15 20:03:27 -05:00
|
|
|
}
|
|
|
|
|
2015-03-03 05:36:12 -05:00
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e ObjectNotFound) Error() string {
|
|
|
|
return "Object not Found: " + e.Bucket + "#" + e.Object
|
2015-01-21 02:16:06 -05:00
|
|
|
}
|
|
|
|
|
2015-03-03 05:36:12 -05:00
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e APINotImplemented) Error() string {
|
2015-03-06 00:07:19 -05:00
|
|
|
return "Api not implemented: " + e.API
|
2015-02-15 20:03:27 -05:00
|
|
|
}
|
|
|
|
|
2015-03-03 05:36:12 -05:00
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e ObjectExists) Error() string {
|
|
|
|
return "Object exists: " + e.Bucket + "#" + e.Object
|
2015-01-21 02:16:06 -05:00
|
|
|
}
|
2015-01-21 03:50:23 -05:00
|
|
|
|
2015-03-03 05:36:12 -05:00
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e BucketNameInvalid) Error() string {
|
|
|
|
return "Bucket name invalid: " + e.Bucket
|
2015-01-21 03:50:23 -05:00
|
|
|
}
|
|
|
|
|
2015-03-03 05:36:12 -05:00
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e BucketExists) Error() string {
|
|
|
|
return "Bucket exists: " + e.Bucket
|
2015-01-21 03:50:23 -05:00
|
|
|
}
|
2015-01-24 18:35:01 -05:00
|
|
|
|
2015-03-03 05:36:12 -05:00
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e BucketNotFound) Error() string {
|
|
|
|
return "Bucket not Found: " + e.Bucket
|
2015-01-24 18:35:01 -05:00
|
|
|
}
|
2015-01-25 20:41:59 -05:00
|
|
|
|
2015-03-03 05:36:12 -05:00
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e ObjectNameInvalid) Error() string {
|
|
|
|
return "Object name invalid: " + e.Bucket + "#" + e.Object
|
2015-01-25 20:41:59 -05:00
|
|
|
}
|
2015-01-27 21:43:55 -05:00
|
|
|
|
2015-03-03 05:36:12 -05:00
|
|
|
// Return string an error formatted as the given text
|
2015-03-05 23:32:04 -05:00
|
|
|
func (e BackendCorrupted) Error() string {
|
|
|
|
return "Backend corrupted: " + e.Path
|
2015-01-27 21:43:55 -05:00
|
|
|
}
|