Skip to content

Commit 358b7f5

Browse files
committed
handle ZIP close error
1 parent 5ee0d64 commit 358b7f5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

server/utils/emulator.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,12 @@ func (m EmulatorAPIServer) AllContractsZip(w http.ResponseWriter, r *http.Reques
326326
w.WriteHeader(http.StatusOK)
327327

328328
zipW := zip.NewWriter(w)
329-
defer zipW.Close()
329+
defer func() {
330+
err := zipW.Close()
331+
if err != nil {
332+
w.WriteHeader(http.StatusInternalServerError)
333+
}
334+
}()
330335

331336
for accountIndex := 1; ; accountIndex++ {
332337
account, err := m.emulator.GetAccountByIndex(uint(accountIndex))
@@ -353,5 +358,4 @@ func (m EmulatorAPIServer) AllContractsZip(w http.ResponseWriter, r *http.Reques
353358
}
354359
}
355360
}
356-
357361
}

0 commit comments

Comments
 (0)