Skip to content

Commit 8c666a0

Browse files
github-actions[bot]d4x1HouLinwei
authored
fix(zentao): update error message when testing connection fails (#7175) (#7176)
Co-authored-by: Lynwee <linwei.hou@merico.dev> Co-authored-by: houlinwei <timeror@gmail.com>
1 parent c18dfcf commit 8c666a0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

backend/plugins/zentao/models/access_token.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ type ApiAccessTokenRequest struct {
2424

2525
type ApiAccessTokenResponse struct {
2626
Token string `json:"token"`
27+
Error string `json:"error"`
2728
}

backend/plugins/zentao/models/connection.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ func (connection ZentaoConn) PrepareApiClient(apiClient plugin.ApiClient) errors
5050
return errors.HttpStatus(http.StatusBadRequest).Wrap(err, "failed UnmarshalResponse for tokenResBody")
5151
}
5252
if tokenResBody.Token == "" {
53-
return errors.HttpStatus(http.StatusBadRequest).New("failed to request access token")
53+
msg := "failed to request access token"
54+
if tokenResBody.Error != "" {
55+
msg = tokenResBody.Error
56+
}
57+
return errors.HttpStatus(http.StatusBadRequest).New(msg)
5458
}
5559
apiClient.SetHeaders(map[string]string{
5660
"Token": fmt.Sprintf("%v", tokenResBody.Token),

0 commit comments

Comments
 (0)