Exemplo n.º 1
0
func callRet(ret interface{}, resp *http.Response) (code int, err error) {
	defer resp.Body.Close()
	code = resp.StatusCode
	if code/100 == 2 {
		if ret != nil && resp.ContentLength != 0 {
			err = json.NewDecoder(resp.Body).Decode(ret)
			if err != nil {
				code = api.UnexceptedResponse
			}
		}
	} else {
		if resp.ContentLength != 0 {
			if ct, ok := resp.Header["Content-Type"]; ok && ct[0] == "application/json" {
				var ret1 ErrorRet
				json.NewDecoder(resp.Body).Decode(&ret1)
				if ret1.Error != "" {
					err = errors.New(ret1.Error)
					return
				}
			}
		}
		err = api.Errno(code)
	}
	return
}
Exemplo n.º 2
0
	Conflicted        = 609 // FS: 冲突
	NotAFile          = 610 // FS: 指定的 Entry 不是一个文件
	NotADirectory     = 611 // FS: 指定的 Entry 不是一个目录
	NoSuchEntry       = 612 // FS: 指定的 Entry 不存在或已经 Deleted
	NotADeletedEntry  = 613 // FS: 指定的 Entry 不是一个已经删除的条目
	EntryExists       = 614 // FS: 要创建的 Entry 已经存在
	CircularAction    = 615 // FS: 操作发生循环,无法完成
	NoSuchDirectory   = 616 // FS: Move 操作的 Parent Directory 不存在
	Locked            = 617 // FS: 要操作的 Entry 被锁,操作暂时无法进行
	DirectoryNotEmpty = 618 // FS: rmdir - directory not empty
	BadData           = 619 // FS: 数据已被破坏
	ConditionNotMeet  = 620 // FS: 条件不满足
)

var (
	EOutOfSpace        = api.Errno(OutOfSpace)
	EFileModified      = api.Errno(FileModified)
	EConflicted        = api.Errno(Conflicted)
	ENotAFile          = api.Errno(NotAFile)
	ENotADirectory     = api.Errno(NotADirectory)
	ENoSuchEntry       = api.Errno(NoSuchEntry)
	ENotADeletedEntry  = api.Errno(NotADeletedEntry)
	EEntryExists       = api.Errno(EntryExists)
	ECircularAction    = api.Errno(CircularAction)
	ENoSuchDirectory   = api.Errno(NoSuchDirectory)
	ELocked            = api.Errno(Locked)
	EDirectoryNotEmpty = api.Errno(DirectoryNotEmpty)
	EBadData           = api.Errno(BadData)
	EConditionNotMeet  = api.Errno(ConditionNotMeet)
)
Exemplo n.º 3
0
	. "qbox/api/conf"
	"qbox/rpc"
	"strconv"
	"time"
)

// ----------------------------------------------------------

const (
	FileModified = 608 // RS: 文件被修改(see fs.GetIfNotModified)
	NoSuchEntry  = 612 // RS: 指定的 Entry 不存在或已经 Deleted
	EntryExists  = 614 // RS: 要创建的 Entry 已经存在
)

var (
	EFileModified = api.Errno(FileModified)
	ENoSuchEntry  = api.Errno(NoSuchEntry)
	EEntryExists  = api.Errno(EntryExists)
)

func init() {
	api.RegisterErrno([]api.ErrnoMsg{
		{FileModified, "file modified"},
		{NoSuchEntry, "no such file or directory"},
		{EntryExists, "file exists"},
	})
}

// ----------------------------------------------------------

func EncodeURI(uri string) string {