Add more error handling
This commit is contained in:
parent
8ae65e4b73
commit
06b7ddf175
1 changed files with 13 additions and 2 deletions
15
app/app.go
15
app/app.go
|
@ -237,8 +237,19 @@ func (a *App) uploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Rename(tf.Name(), of)
|
if err := os.Rename(tf.Name(), of); err != nil {
|
||||||
os.Remove(fn)
|
err := fmt.Errorf("error renaming temporary file to output file: %w", err)
|
||||||
|
log.Error(err)
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.Remove(fn); err != nil {
|
||||||
|
err := fmt.Errorf("error removing file: %w", err)
|
||||||
|
log.Error(err)
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Fprintf(w, "Video successfully uploaded!")
|
fmt.Fprintf(w, "Video successfully uploaded!")
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue