Skip to content

Commit

Permalink
add error log for room create and recreate.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Oct 1, 2023
1 parent 94f8fbb commit c620c70
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/api/rooms.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -93,25 +98,29 @@ 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
}
}

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
}
Expand Down

0 comments on commit c620c70

Please sign in to comment.