Skip to content

Commit 3505ff1

Browse files
committed
Set error message on failure for content resource
1 parent 988e584 commit 3505ff1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

sumologic/sumologic_content.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (s *Client) CreateOrUpdateContent(content Content, timeout time.Duration, o
105105
return contentId, nil
106106
}
107107

108-
func waitForJob(url string, timeout time.Duration, s *Client) (Status, error) {
108+
func waitForJob(url string, timeout time.Duration, s *Client) (*Status, error) {
109109
conf := &resource.StateChangeConf{
110110
Pending: []string{
111111
"InProgress",
@@ -125,8 +125,8 @@ func waitForJob(url string, timeout time.Duration, s *Client) (Status, error) {
125125
return nil, "", err
126126
}
127127

128-
if status.Status == "failed" {
129-
return status, status.Status, fmt.Errorf("job failed: %s", status.StatusMessage)
128+
if status.Status == "Failed" {
129+
return status, status.Status, fmt.Errorf("Failed - %s", status.Error)
130130
}
131131

132132
return status, status.Status, nil
@@ -137,6 +137,10 @@ func waitForJob(url string, timeout time.Duration, s *Client) (Status, error) {
137137
}
138138

139139
result, err := conf.WaitForState()
140-
log.Printf("[DEBUG] job result: %v", result)
141-
return result.(Status), err
140+
log.Printf("[DEBUG] Done waiting for job; err: %s, result: %v", err, result)
141+
if status, ok := result.(Status); ok {
142+
return &status, err
143+
} else {
144+
return nil, err
145+
}
142146
}

0 commit comments

Comments
 (0)