Add missing strongly typed errors for Donut

This commit is contained in:
Harshavardhana
2015-06-23 11:44:32 -07:00
parent d0dd047bef
commit 2fd52ca284
13 changed files with 208 additions and 81 deletions
+2 -3
View File
@@ -18,7 +18,6 @@ package donut
import (
"encoding/json"
"errors"
"fmt"
"io"
"os"
@@ -111,7 +110,7 @@ func (d donut) makeDonutBucket(bucketName, acl string) error {
return iodine.New(err, nil)
}
if _, ok := d.buckets[bucketName]; ok {
return iodine.New(errors.New("bucket exists"), nil)
return iodine.New(BucketExists{Bucket: bucketName}, nil)
}
bucket, bucketMetadata, err := NewBucket(bucketName, acl, d.name, d.nodes)
if err != nil {
@@ -169,7 +168,7 @@ func (d donut) getDonutBuckets() error {
for _, dir := range dirs {
splitDir := strings.Split(dir.Name(), "$")
if len(splitDir) < 3 {
return iodine.New(errors.New("corrupted backend"), nil)
return iodine.New(CorruptedBackend{Backend: dir.Name()}, nil)
}
bucketName := splitDir[0]
// we dont need this NewBucket once we cache from makeDonutBucket()