Skip to content

Commit bc641ab

Browse files
arschlesAaron Schlesinger
authored andcommitted
fix(controller.go): return more descriptive error message on endpoint failures
1 parent 2c29467 commit bc641ab

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

pkg/gitreceive/controller.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,13 @@ package gitreceive
33
import (
44
"bytes"
55
"encoding/json"
6-
"errors"
76
"fmt"
87
"net/http"
98
"strings"
109

1110
"github.com/deis/builder/pkg"
1211
)
1312

14-
var (
15-
errControllerNotFound = errors.New("Deis controller not found. Is it running?")
16-
errControllerServiceUnavailable = errors.New("Deis controller was unavailable. Is it healthy?")
17-
)
18-
1913
type unexpectedControllerStatusCode struct {
2014
endpoint string
2115
expected int
@@ -67,12 +61,9 @@ func getAppConfig(conf *Config, builderKey, userName, appName string) (*pkg.Conf
6761
}
6862
defer res.Body.Close()
6963

70-
if res.StatusCode == 404 {
71-
return nil, errControllerNotFound
72-
} else if res.StatusCode != 200 {
64+
if res.StatusCode != 200 {
7365
return nil, newUnexpectedControllerStatusCode(url, 200, res.StatusCode)
7466
}
75-
7667
ret := &pkg.Config{}
7768
if err := json.NewDecoder(res.Body).Decode(ret); err != nil {
7869
return nil, err
@@ -100,11 +91,7 @@ func publishRelease(conf *Config, builderKey string, buildHook *pkg.BuildHook) (
10091

10192
defer res.Body.Close()
10293

103-
if res.StatusCode == http.StatusNotFound {
104-
return nil, errControllerNotFound
105-
} else if res.StatusCode == http.StatusServiceUnavailable {
106-
return nil, errControllerServiceUnavailable
107-
} else if res.StatusCode != 200 {
94+
if res.StatusCode != 200 {
10895
return nil, newUnexpectedControllerStatusCode(url, 200, res.StatusCode)
10996
}
11097

0 commit comments

Comments
 (0)