File: err.go

package info (click to toggle)
golang-doozer 0.0~git20130909-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 224 kB
  • ctags: 283
  • sloc: makefile: 11
file content (43 lines) | stat: -rw-r--r-- 867 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package doozer

import (
	"errors"
)

var (
	ErrNoAddrs     = errors.New("no known address")
	ErrBadTag      = errors.New("bad tag")
	ErrClosed      = errors.New("closed")
	ErrWaitTimeout = errors.New("wait timeout")
)

var (
	ErrOther    response_Err = response_OTHER
	ErrNotDir   response_Err = response_NOTDIR
	ErrIsDir    response_Err = response_ISDIR
	ErrNoEnt    response_Err = response_NOENT
	ErrRange    response_Err = response_RANGE
	ErrOldRev   response_Err = response_REV_MISMATCH
	ErrTooLate  response_Err = response_TOO_LATE
	ErrReadonly response_Err = response_READONLY
)

type Error struct {
	Err    error
	Detail string
}

func newError(t *txn) *Error {
	return &Error{
		Err:    *t.resp.ErrCode,
		Detail: t.resp.GetErrDetail(),
	}
}

func (e *Error) Error() (s string) {
	s = e.Err.Error()
	if e.Detail != "" {
		s += ": " + e.Detail
	}
	return s
}