Skip to content

Commit

Permalink
Better error info
Browse files Browse the repository at this point in the history
Better error info
  • Loading branch information
vy-bot authored Mar 7, 2023
1 parent fca08d3 commit 744f417
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/providers/custom/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (p *Provider) Send(message, CliFormat string) error {
var buf bytes.Buffer
err = tmpl.Execute(&buf, data)
if err != nil {
err = errors.Wrap(err, fmt.Sprintf("failed to execute custom sprig template for id: %s ", pr.ID))
err = errors.Wrap(err, fmt.Sprintf("failed to execute custom sprig template for id: %s: %s", pr.ID, data))
CustomErr = multierr.Append(CustomErr, err)
continue
}
Expand All @@ -75,7 +75,7 @@ func (p *Provider) Send(message, CliFormat string) error {
// Escape the message to a JSON string
b, err := json.Marshal(message)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("failed to escape message to JSON for id: %s ", pr.ID))
return errors.Wrap(err, fmt.Sprintf("failed to escape message to JSON for id: %s: %s", pr.ID, message))
}
dataJsonString := string(b)

Expand All @@ -87,11 +87,10 @@ func (p *Provider) Send(message, CliFormat string) error {
}

body := bytes.NewBufferString(msg)
gologger.Verbose().Msgf("custom body sent: %s", msg)

r, err := http.NewRequest(pr.CustomMethod, pr.CustomWebhookURL, body)
if err != nil {
err = errors.Wrap(err, fmt.Sprintf("failed to send custom notification for id: %s ", pr.ID))
err = errors.Wrap(err, fmt.Sprintf("failed to send custom notification for id: %s: %s", pr.ID, msg))
CustomErr = multierr.Append(CustomErr, err)
continue
}
Expand All @@ -102,11 +101,11 @@ func (p *Provider) Send(message, CliFormat string) error {

_, err = httpreq.NewClient().Do(r)
if err != nil {
err = errors.Wrap(err, fmt.Sprintf("failed to send custom notification for id: %s ", pr.ID))
err = errors.Wrap(err, fmt.Sprintf("failed to send custom notification for id: %s: %s", pr.ID, msg))
CustomErr = multierr.Append(CustomErr, err)
continue
}
gologger.Verbose().Msgf("custom notification sent for id: %s", pr.ID)
gologger.Verbose().Msgf("custom notification sent for id: %s: %s", pr.ID, msg)
}
return CustomErr
}
Expand Down

0 comments on commit 744f417

Please sign in to comment.