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-01-27 21:43:55 -05:00
|
|
|
type BackendError struct {
|
|
|
|
Path string
|
|
|
|
}
|
|
|
|
|
2015-01-21 02:16:06 -05:00
|
|
|
type GenericError struct {
|
2015-01-21 15:44:09 -05:00
|
|
|
Bucket string
|
|
|
|
Path string
|
2015-01-21 02:16:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type ObjectExists struct {
|
2015-01-21 15:44:09 -05:00
|
|
|
Bucket string
|
|
|
|
Key string
|
2015-01-21 02:16:06 -05:00
|
|
|
}
|
|
|
|
|
2015-01-25 20:41:59 -05:00
|
|
|
type ObjectNotFound GenericObjectError
|
2015-01-21 03:50:23 -05:00
|
|
|
|
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-01-25 20:41:59 -05:00
|
|
|
type GenericObjectError struct {
|
|
|
|
Bucket string
|
|
|
|
Object string
|
|
|
|
}
|
|
|
|
|
|
|
|
type ImplementationError struct {
|
|
|
|
Bucket string
|
|
|
|
Object string
|
|
|
|
Err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self ImplementationError) Error() string {
|
|
|
|
error := ""
|
|
|
|
if self.Bucket != "" {
|
|
|
|
error = error + "Bucket: " + self.Bucket + " "
|
|
|
|
}
|
|
|
|
if self.Object != "" {
|
|
|
|
error = error + "Object: " + self.Object + " "
|
|
|
|
}
|
|
|
|
error = error + "Error: " + self.Err.Error()
|
|
|
|
return error
|
|
|
|
}
|
|
|
|
|
|
|
|
func EmbedError(bucket, object string, err error) ImplementationError {
|
|
|
|
return ImplementationError{
|
|
|
|
Bucket: bucket,
|
|
|
|
Object: object,
|
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 21:43:55 -05:00
|
|
|
type BackendCorrupted BackendError
|
2015-01-24 18:35:01 -05:00
|
|
|
type BucketNameInvalid GenericBucketError
|
|
|
|
type BucketExists GenericBucketError
|
|
|
|
type BucketNotFound GenericBucketError
|
2015-01-25 20:41:59 -05:00
|
|
|
type ObjectNameInvalid GenericObjectError
|
2015-01-21 02:16:06 -05:00
|
|
|
|
|
|
|
func (self ObjectNotFound) Error() string {
|
2015-01-25 20:41:59 -05:00
|
|
|
return "Object not Found: " + self.Bucket + "#" + self.Object
|
2015-01-21 02:16:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self ObjectExists) Error() string {
|
2015-01-21 15:44:09 -05:00
|
|
|
return "Object exists: " + self.Bucket + "#" + self.Key
|
2015-01-21 02:16:06 -05:00
|
|
|
}
|
2015-01-21 03:50:23 -05:00
|
|
|
|
|
|
|
func (self BucketNameInvalid) Error() string {
|
2015-01-21 15:44:09 -05:00
|
|
|
return "Bucket name invalid: " + self.Bucket
|
2015-01-21 03:50:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self BucketExists) Error() string {
|
2015-01-21 15:44:09 -05:00
|
|
|
return "Bucket exists: " + self.Bucket
|
2015-01-21 03:50:23 -05:00
|
|
|
}
|
2015-01-24 18:35:01 -05:00
|
|
|
|
|
|
|
func (self BucketNotFound) Error() string {
|
|
|
|
return "Bucket not Found: " + self.Bucket
|
|
|
|
}
|
2015-01-25 20:41:59 -05:00
|
|
|
|
|
|
|
func (self ObjectNameInvalid) Error() string {
|
|
|
|
return "Object name invalid: " + self.Bucket + "#" + self.Object
|
|
|
|
}
|
2015-01-27 21:43:55 -05:00
|
|
|
|
|
|
|
func (self BackendCorrupted) Error() string {
|
|
|
|
return "Backend corrupted: " + self.Path
|
|
|
|
}
|