fix: improve error reporting for message sending failures

- Enhance error reporting by including the response body in the error message when message sending fails.
- Remove the previous error message that only included the status code.

Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
appleboy
2025-03-08 17:42:58 +08:00
parent c84a5276cb
commit 464bf4772f
+3 -1
View File
@@ -322,7 +322,9 @@ func (p *Plugin) SendMessage(ctx context.Context) error {
defer resp.Body.Close()
if resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("failed to send message, status code: %d", resp.StatusCode)
bodyBytes, _ := io.ReadAll(resp.Body)
bodyString := string(bodyBytes)
return fmt.Errorf("failed to send message, status code: %d, response: %s", resp.StatusCode, bodyString)
}
return nil