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>
diff --git a/backend/plugins/zentao/models/access_token.go b/backend/plugins/zentao/models/access_token.go
index 60bf261..d084348 100644
--- a/backend/plugins/zentao/models/access_token.go
+++ b/backend/plugins/zentao/models/access_token.go
@@ -24,4 +24,5 @@
type ApiAccessTokenResponse struct {
Token string `json:"token"`
+ Error string `json:"error"`
}
diff --git a/backend/plugins/zentao/models/connection.go b/backend/plugins/zentao/models/connection.go
index ccce201..0554450 100644
--- a/backend/plugins/zentao/models/connection.go
+++ b/backend/plugins/zentao/models/connection.go
@@ -50,7 +50,11 @@
return errors.HttpStatus(http.StatusBadRequest).Wrap(err, "failed UnmarshalResponse for tokenResBody")
}
if tokenResBody.Token == "" {
- return errors.HttpStatus(http.StatusBadRequest).New("failed to request access token")
+ msg := "failed to request access token"
+ if tokenResBody.Error != "" {
+ msg = tokenResBody.Error
+ }
+ return errors.HttpStatus(http.StatusBadRequest).New(msg)
}
apiClient.SetHeaders(map[string]string{
"Token": fmt.Sprintf("%v", tokenResBody.Token),