diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -120,8 +120,14 @@ func main() { // Send the NATS request and wait synchronously for a reply (timeout: 30 seconds) reply, err := nc.RequestMsg(&msg, 30*time.Second) if err != nil { - http.Error(w, "Error processing request", http.StatusInternalServerError) log.Println("NATS request error:", err) + + // Handle specific NATS error cases + if err == nats.ErrNoResponders || strings.Contains(err.Error(), "no responders") { + http.Error(w, "No service available to handle request", http.StatusNotFound) + } else { + http.Error(w, "Error processing request", http.StatusInternalServerError) + } return } |