Skip to content

Commit

Permalink
Merge pull request #26 from jjeffery/not-found-error
Browse files Browse the repository at this point in the history
Return os.ErrNotExist if file not found
  • Loading branch information
elazarl authored Aug 22, 2016
2 parents e1a2a7e + 446cd78 commit 9a6736e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions assetfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path"
"path/filepath"
"strings"
"time"
)

Expand Down Expand Up @@ -153,6 +154,12 @@ func (fs *AssetFS) Open(name string) (http.File, error) {
if children, err := fs.AssetDir(name); err == nil {
return NewAssetDirectory(name, children, fs), nil
} else {
// If the error is not found, return an error that will
// result in a 404 error. Otherwise the server returns
// a 500 error for files not found.
if strings.Contains(err.Error(), "not found") {
return nil, os.ErrNotExist
}
return nil, err
}
}

1 comment on commit 9a6736e

@c4milo
Copy link

@c4milo c4milo commented on 9a6736e Aug 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This one was driving me nuts.

Please sign in to comment.