mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
update errors.
This commit is contained in:
parent
c77d2b0305
commit
4e6a78fb54
@ -31,7 +31,7 @@ func (h *RoomHandler) ScreenConfiguration(w http.ResponseWriter, r *http.Request
|
|||||||
size := h.remote.GetScreenSize()
|
size := h.remote.GetScreenSize()
|
||||||
|
|
||||||
if size == nil {
|
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
|
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) {
|
func (h *RoomHandler) ScreenConfigurationChange(w http.ResponseWriter, r *http.Request) {
|
||||||
data := &ScreenConfiguration{}
|
data := &ScreenConfiguration{}
|
||||||
if err := render.Bind(r, data); err != nil {
|
if err := render.Bind(r, data); err != nil {
|
||||||
render.Render(w, r, utils.ErrInvalidRequest(err))
|
render.Render(w, r, utils.ErrBadRequest(err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.remote.ChangeResolution(data.Width, data.Height, data.Rate); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := broadcast.ScreenConfiguration(h.sessions, "-todo-session-id-", data.Width, data.Height, data.Rate); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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{
|
return &ErrResponse{
|
||||||
Err: err,
|
Err: err,
|
||||||
HTTPStatusCode: 400,
|
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(),
|
ErrorText: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user