mirror of
https://github.com/appleboy/drone-discord.git
synced 2026-06-04 18:33:47 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user