Skip to content

Commit 63c102f

Browse files
committed
errror messages
1 parent 70dc2fe commit 63c102f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

local/bin/post-commit.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,21 @@ func send(commit Commit) error {
7676

7777
if response.StatusCode != http.StatusOK {
7878

79-
return fmt.Errorf("Error when sending a commit to Postgres-CI: %v", response.Status)
79+
if response.StatusCode == http.StatusBadRequest {
80+
81+
var message struct {
82+
Success bool `json:"success"`
83+
Code int `json:"code"`
84+
Error string `json:"error"`
85+
}
86+
87+
if err := json.NewDecoder(response.Body).Decode(&message); err == nil {
88+
89+
return fmt.Errorf("Error when sending a commit to Postgres-CI: %s", message.Error)
90+
}
91+
}
92+
93+
return fmt.Errorf("Error when sending a commit to Postgres-CI: %s", response.Status)
8094
}
8195

8296
fmt.Printf("\nCommit %s was sent to Postgres-CI server (%s://%s)\n\n", commit.ID, _url.Scheme, _url.Host)

server-side/bin/post-receive.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ func send(push git.Push) error {
9595

9696
if response.StatusCode != http.StatusOK {
9797

98+
if response.StatusCode == http.StatusBadRequest {
99+
100+
var message struct {
101+
Success bool `json:"success"`
102+
Code int `json:"code"`
103+
Error string `json:"error"`
104+
}
105+
106+
if err := json.NewDecoder(response.Body).Decode(&message); err == nil {
107+
108+
return fmt.Errorf("Error when sending a push to Postgres-CI: %s", message.Error)
109+
}
110+
}
111+
98112
return fmt.Errorf("Error when sending a push to Postgres-CI: %s", response.Status)
99113
}
100114

0 commit comments

Comments
 (0)