diff --git a/internal/api/room/screen.go b/internal/api/room/screen.go index 64289fa5..30932939 100644 --- a/internal/api/room/screen.go +++ b/internal/api/room/screen.go @@ -31,7 +31,7 @@ func (h *RoomHandler) ScreenConfiguration(w http.ResponseWriter, r *http.Request size := h.remote.GetScreenSize() if size == nil { - render.Render(w, r, utils.ErrMessage(500, "Not implmented.")) + render.Render(w, r, utils.ErrMessage(500, "Unable to get screen configuration.")) return } @@ -45,17 +45,17 @@ func (h *RoomHandler) ScreenConfiguration(w http.ResponseWriter, r *http.Request func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.Request) { data := &ScreenConfiguration{} if err := render.Bind(r, data); err != nil { - render.Render(w, r, utils.ErrInvalidRequest(err)) + render.Render(w, r, utils.ErrBadRequest(err)) return } if err := h.remote.ChangeResolution(data.Width, data.Height, data.Rate); err != nil { - render.Render(w, r, utils.ErrInvalidRequest(err)) + render.Render(w, r, utils.ErrUnprocessableEntity(err)) return } if err := broadcast.ScreenConfiguration(h.sessions, "-todo-session-id-", data.Width, data.Height, data.Rate); err != nil { - render.Render(w, r, utils.ErrInvalidRequest(err)) + render.Render(w, r, utils.ErrInternalServer(err)) return } diff --git a/internal/api/utils/error.go b/internal/api/utils/error.go index 8b0ed52e..05ee8ed3 100644 --- a/internal/api/utils/error.go +++ b/internal/api/utils/error.go @@ -36,11 +36,20 @@ func ErrMessage(HTTPStatusCode int, StatusText string) render.Renderer { } } -func ErrInvalidRequest(err error) render.Renderer { +func ErrBadRequest(err error) render.Renderer { return &ErrResponse{ Err: err, HTTPStatusCode: 400, - StatusText: "Invalid request.", + StatusText: "Bad request.", + ErrorText: err.Error(), + } +} + +func ErrUnprocessableEntity(err error) render.Renderer { + return &ErrResponse{ + Err: err, + HTTPStatusCode: 400, + StatusText: "Unprocessable Entity.", ErrorText: err.Error(), } }