return a better descriptive error when the blob isn't found

This commit is contained in:
Niko Storni 2020-07-09 03:12:33 +02:00
parent 5c91051b78
commit 34ca7847d0

View file

@ -70,6 +70,10 @@ func (s *Server) Start(address string) error {
requestedBlob := vars["hash"]
blob, err := s.store.Get(requestedBlob)
if err != nil {
if errors.Is(err, store.ErrBlobNotFound) {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
fmt.Printf("%s: %s", requestedBlob, errors.FullTrace(err))
s.logError(err)
http.Error(w, err.Error(), http.StatusBadRequest)