projects
/
epoint
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add NotFoundError to store
[epoint]
/
store
/
store.go
diff --git
a/store/store.go
b/store/store.go
index
8bdf317
..
2a6d2f8
100644
(file)
--- a/
store/store.go
+++ b/
store/store.go
@@
-17,6
+17,14
@@
type Conn struct {
path string
}
path string
}
+type NotFoundError struct {
+ path string
+}
+
+func (e NotFoundError) Error() string {
+ return "not found: " + e.path
+}
+
func Open(root string) (c *Conn, err error) {
c = new(Conn)
c.path, err = filepath.Abs(root)
func Open(root string) (c *Conn, err error) {
c = new(Conn)
c.path, err = filepath.Abs(root)
@@
-31,7
+39,13
@@
func Open(root string) (c *Conn, err error) {
}
func (c *Conn) Get(name, k string) (v []byte, err error) {
}
func (c *Conn) Get(name, k string) (v []byte, err error) {
- return ioutil.ReadFile(filepath.Join(c.path, name, k))
+ v, err = ioutil.ReadFile(filepath.Join(c.path, name, k))
+ if err != nil {
+ if p, ok := err.(*os.PathError); ok && p.Err == os.ENOENT {
+ err = NotFoundError{name+"/"+k}
+ }
+ }
+ return
}
func (c *Conn) Ensure(name string) (err error) {
}
func (c *Conn) Ensure(name string) (err error) {