Use generic typed error pattern

The codebase doesn't yet use the explicitly typed error pattern. To keep
things consistent, lets use the generic error type.
This commit is contained in:
akarki15
2016-11-12 12:30:15 -05:00
parent 1b4902f196
commit 68db934507
2 changed files with 3 additions and 8 deletions

View File

@@ -90,12 +90,6 @@ func ReadAll(path string) (map[string]Bookmark, error) {
return results, nil
}
type ErrNonExistingBookmark string
func (e ErrNonExistingBookmark) Error() string {
return fmt.Sprintf("couldn't find a bookmark with name %s", e)
}
func GetBookmark(bookmarkPath string, bookmarkName string) (Bookmark, error) {
bookmarks, err := ReadAll(bookmarkPath)
if err != nil {
@@ -103,7 +97,7 @@ func GetBookmark(bookmarkPath string, bookmarkName string) (Bookmark, error) {
}
bookmark, ok := bookmarks[bookmarkName]
if !ok {
return Bookmark{}, ErrNonExistingBookmark(bookmarkName)
return Bookmark{}, fmt.Errorf("couldn't find a bookmark with name %s", bookmarkName)
}
return bookmark, nil