Example #1
0
// wrapErr wraps s.err to a filestore-specific error, if possible
func (s *errStore) wrapErr(err error) error {
	if os.IsNotExist(err) {
		if pathError, ok := err.(*os.PathError); ok {
			return store.NewPathNotFoundError("path not found: " + pathError.Path)
		}
		return store.NewPathNotFoundError(fmt.Sprintf("path not found: %s", err))
	}
	return err
}
Example #2
0
File: pathio.go Project: fxnn/gone
func (i *pathIO) assertPathInsideContentRoot(p gopath.GoPath) {
	if i.hasErr() {
		return
	}

	if !i.isPathInsideContentRoot(p) {
		i.setErr(store.NewPathNotFoundError(
			fmt.Sprintf("%s is not inside content root %s", p, i.contentRoot),
		))
	}
}
Example #3
0
func (s *errStore) prependErr(prefix string) {
	if s.err != nil {
		var msg = fmt.Sprintf("%s: %s", prefix, s.err.Error())
		switch {
		case store.IsPathNotFoundError(s.err):
			s.err = store.NewPathNotFoundError(msg)
		case store.IsAccessDeniedError(s.err):
			s.err = store.NewAccessDeniedError(msg)
		default:
			s.err = fmt.Errorf(msg)
		}
	}
}
Example #4
0
File: pathio.go Project: fxnn/gone
func (i *pathIO) assertFileIsNotHidden(p gopath.GoPath) {
	if i.hasErr() {
		return
	}
	if p.HasErr() {
		i.syncedErrs(p)
		return
	}

	if strings.HasPrefix(p.Base(), ".") {
		i.setErr(store.NewPathNotFoundError(fmt.Sprintf("%s is a hidden file and may not be displayed", p)))
	}

	// HINT: recursive call, ending at content root
	if i.isPathInsideContentRoot(p) {
		i.assertFileIsNotHidden(p.ToSlash().Dir())
	}
}
Example #5
0
func (s *MockStore) FileSizeForRequest(request *http.Request) int64 {
	if !s.exists {
		s.err = store.NewPathNotFoundError("mocked PathNotFoundError")
	}
	return 0
}
Example #6
0
func (s *MockStore) Delete(request *http.Request) {
	if !s.exists {
		s.err = store.NewPathNotFoundError("mocked PathNotFoundError")
	}
}
Example #7
0
func (s *MockStore) ReadString(request *http.Request) string {
	if !s.exists {
		s.err = store.NewPathNotFoundError("mocked PathNotFoundError")
	}
	return ""
}
Example #8
0
func (s *MockStore) OpenReader(request *http.Request) io.ReadCloser {
	if !s.exists {
		s.err = store.NewPathNotFoundError("mocked PathNotFoundError")
	}
	return nil
}
Example #9
0
func (s *MockStore) MimeTypeForRequest(request *http.Request) string {
	if !s.exists {
		s.err = store.NewPathNotFoundError("mocked PathNotFoundError")
	}
	return s.mimeType
}
Example #10
0
func (s *MockStore) ModTimeForRequest(request *http.Request) time.Time {
	if !s.exists {
		s.err = store.NewPathNotFoundError("mocked PathNotFoundError")
	}
	return time.Now()
}