From c620c70d51487fb2c3a6d2ffb5edaca0fc1eafa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 1 Oct 2023 14:59:43 +0200 Subject: [PATCH] add error log for room create and recreate. --- internal/api/rooms.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/api/rooms.go b/internal/api/rooms.go index beec9ea..bbdff96 100644 --- a/internal/api/rooms.go +++ b/internal/api/rooms.go @@ -52,17 +52,20 @@ func (manager *ApiManagerCtx) roomCreate(w http.ResponseWriter, r *http.Request) ID, err := manager.rooms.Create(request) if err != nil { + manager.logger.Error().Err(err).Msg("create: failed to create room") http.Error(w, err.Error(), 500) return } if err := manager.rooms.Start(ID); err != nil { + manager.logger.Error().Err(err).Msg("create: failed to start room") http.Error(w, err.Error(), 500) return } response, err := manager.rooms.GetEntry(ID) if err != nil { + manager.logger.Error().Err(err).Msg("create: failed to get room entry") http.Error(w, err.Error(), 500) return } @@ -76,12 +79,14 @@ func (manager *ApiManagerCtx) roomRecreate(w http.ResponseWriter, r *http.Reques entry, err := manager.rooms.GetEntry(roomId) if err != nil { + manager.logger.Error().Err(err).Msg("recreate: failed to get room entry") http.Error(w, err.Error(), 500) return } settings, err := manager.rooms.GetSettings(roomId) if err != nil { + manager.logger.Error().Err(err).Msg("recreate: failed to get room settings") http.Error(w, err.Error(), 500) return } @@ -93,18 +98,21 @@ func (manager *ApiManagerCtx) roomRecreate(w http.ResponseWriter, r *http.Reques } if err := manager.rooms.Remove(roomId); err != nil { + manager.logger.Error().Err(err).Msg("recreate: failed to remove room") http.Error(w, err.Error(), 500) return } ID, err := manager.rooms.Create(*settings) if err != nil { + manager.logger.Error().Err(err).Msg("recreate: failed to create room") http.Error(w, err.Error(), 500) return } if entry.Running { if err := manager.rooms.Start(ID); err != nil { + manager.logger.Error().Err(err).Msg("recreate: failed to start room") http.Error(w, err.Error(), 500) return } @@ -112,6 +120,7 @@ func (manager *ApiManagerCtx) roomRecreate(w http.ResponseWriter, r *http.Reques response, err := manager.rooms.GetEntry(ID) if err != nil { + manager.logger.Error().Err(err).Msg("recreate: failed to get room entry") http.Error(w, err.Error(), 500) return }