CHANGE: Change Error To ProblemDetails
Build, Push and Deploy CMS / build-push-deploy (push) Successful in 1m52s
Build, Push and Deploy CMS / build-push-deploy (push) Successful in 1m52s
This commit is contained in:
@@ -27,7 +27,7 @@ func ListCategories(w http.ResponseWriter, r *http.Request) {
|
||||
categories, err := services.DB.ListCategories(r.Context())
|
||||
if err != nil {
|
||||
log.Printf("Something Went Wrong Loading Categories: %s", err)
|
||||
writeJSONError(w, http.StatusInternalServerError, "Something Went Wrong Loading Categories")
|
||||
writeProblem(w, http.StatusInternalServerError, "Something Went Wrong Loading Categories")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -52,25 +52,25 @@ func PresignVideoUpload(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req presignRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeJSONError(w, http.StatusBadRequest, "Invalid request.")
|
||||
writeProblem(w, http.StatusBadRequest, "Invalid request.")
|
||||
return
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(req.ContentType, "video/") {
|
||||
writeJSONError(w, http.StatusUnprocessableEntity, fmt.Sprintf("Unsupported file type (%s). Please upload a video.", req.ContentType))
|
||||
writeProblem(w, http.StatusUnprocessableEntity, fmt.Sprintf("Unsupported file type (%s). Please upload a video.", req.ContentType))
|
||||
return
|
||||
}
|
||||
|
||||
filename, err := randomFilename(req.FileName)
|
||||
if err != nil {
|
||||
writeJSONError(w, http.StatusInternalServerError, "Could not prepare upload.")
|
||||
writeProblem(w, http.StatusInternalServerError, "Could not prepare upload.")
|
||||
return
|
||||
}
|
||||
key := videoUploadPrefix + "/" + filename
|
||||
|
||||
presignedURL, err := services.S3Client.GetPresignedURL(r.Context(), key, "video/mp4", time.Hour)
|
||||
if err != nil {
|
||||
writeJSONError(w, http.StatusInternalServerError, "Could not prepare upload.")
|
||||
writeProblem(w, http.StatusInternalServerError, "Could not prepare upload.")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -106,19 +106,19 @@ func CompleteVideoUpload(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req completeRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeJSONError(w, http.StatusBadRequest, "Invalid request.")
|
||||
writeProblem(w, http.StatusBadRequest, "Invalid request.")
|
||||
return
|
||||
}
|
||||
|
||||
title := strings.TrimSpace(req.Title)
|
||||
if title == "" {
|
||||
writeJSONError(w, http.StatusUnprocessableEntity, "Title is required.")
|
||||
writeProblem(w, http.StatusUnprocessableEntity, "Title is required.")
|
||||
return
|
||||
}
|
||||
|
||||
key := strings.TrimSpace(req.Key)
|
||||
if key == "" || !strings.HasPrefix(key, videoUploadPrefix+"/") {
|
||||
writeJSONError(w, http.StatusUnprocessableEntity, "A video file is required.")
|
||||
writeProblem(w, http.StatusUnprocessableEntity, "A video file is required.")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ func CompleteVideoUpload(w http.ResponseWriter, r *http.Request) {
|
||||
jobID, err := services.MediaConvertClient.QueueEncodingJob(r.Context(), key)
|
||||
if err != nil {
|
||||
log.Printf("Something Went Wrong On Creation Of Transcoding Job: %s", err)
|
||||
writeJSONError(w, http.StatusInternalServerError, "Something Went Wrong On Creation Of Transcoding Job")
|
||||
writeProblem(w, http.StatusInternalServerError, "Something Went Wrong On Creation Of Transcoding Job")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ func CompleteVideoUpload(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
if err != nil {
|
||||
log.Printf("Something Went Wrong Saving The Video Record: %s", err)
|
||||
writeJSONError(w, http.StatusInternalServerError, "Something Went Wrong Saving The Video Record")
|
||||
writeProblem(w, http.StatusInternalServerError, "Something Went Wrong Saving The Video Record")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user