Introduce MaxRunningInstancesError type and handle it in StartInstance handler

This commit is contained in:
2025-08-28 20:07:03 +02:00
parent 7d5c68e671
commit 41d8c41188
2 changed files with 10 additions and 2 deletions

View File

@@ -272,6 +272,12 @@ func (h *Handler) StartInstance() http.HandlerFunc {
inst, err := h.InstanceManager.StartInstance(name)
if err != nil {
// Check if error is due to maximum running instances limit
if _, ok := err.(manager.MaxRunningInstancesError); ok {
http.Error(w, err.Error(), http.StatusConflict)
return
}
http.Error(w, "Failed to start instance: "+err.Error(), http.StatusInternalServerError)
return
}