Skip to content

Commit ac9938d

Browse files
committed
fix: bad error handling
1 parent 89cdc62 commit ac9938d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

server/web/web.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,22 @@ loop:
166166
default:
167167
readedBytes, err := reader.Read(b)
168168
if err != nil {
169-
log.Errorf("Errorf reading from reader: %v", err)
169+
if err == io.EOF {
170+
break loop
171+
}
172+
log.Errorf("Errorreading from reader: %v", err)
173+
http.Error(writer, "Error during upload", http.StatusInternalServerError)
170174
return
171175
}
172176

173177
readed += uint64(readedBytes)
174178
_, err = uploadStream.Write(b[0:readedBytes])
175179
if err != nil {
176-
log.Errorf("Errorf writing to stream %v", err)
177-
}
178-
// TODO check error here?
179-
if err == io.EOF {
180-
break loop
180+
if err == io.EOF {
181+
break loop
182+
}
183+
log.Errorf("Error writing: %v", err)
184+
http.Error(writer, "Error during upload", http.StatusInternalServerError)
181185
}
182186
}
183187
}

0 commit comments

Comments
 (0)