Add internal server error page
This commit is contained in:
@ -13,8 +13,18 @@ func init() {
|
||||
log = logger.Logger()
|
||||
}
|
||||
|
||||
func ALL(w http.ResponseWriter, r *http.Request) {
|
||||
component := errorView.Main("Not Found")
|
||||
func NotFound(w http.ResponseWriter, r *http.Request) {
|
||||
component := errorView.NotFound("Not Found")
|
||||
err := component.Render(r.Context(), w)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
log.Error(err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func InternalServerError(w http.ResponseWriter, r *http.Request) {
|
||||
component := errorView.InternalServerError("Internal Server Error")
|
||||
err := component.Render(r.Context(), w)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
@ -28,13 +28,13 @@ func POST(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
handleError(w, err, http.StatusInternalServerError)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
var fileInfo types.FileInfo
|
||||
if err := json.Unmarshal(body, &fileInfo); err != nil {
|
||||
handleError(w, err, http.StatusInternalServerError)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ func POST(w http.ResponseWriter, r *http.Request) {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
upload, err := handleNewUpload(userSession, fileInfo)
|
||||
if err != nil {
|
||||
handleError(w, err, http.StatusInternalServerError)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
respondJSON(w, upload)
|
||||
|
Reference in New Issue
Block a user