Merge pull request #3145 from LinuxSuRen/master
Provide a hunman readable error message instead of the raw
This commit is contained in:
@@ -18,6 +18,7 @@ package jenkins
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"kubesphere.io/kubesphere/pkg/simple/client/devops"
|
"kubesphere.io/kubesphere/pkg/simple/client/devops"
|
||||||
@@ -98,9 +99,20 @@ func (p *Pipeline) GetPipeline() (*devops.Pipeline, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pipeline) ListPipelines() (*devops.PipelineList, error) {
|
func (p *Pipeline) ListPipelines() (*devops.PipelineList, error) {
|
||||||
res, err := p.Jenkins.SendPureRequest(p.Path, p.HttpParameters)
|
res, _, err := p.Jenkins.SendPureRequestWithHeaderResp(p.Path, p.HttpParameters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Error(err)
|
klog.Error(err)
|
||||||
|
if jErr, ok := err.(*JkError); ok {
|
||||||
|
switch jErr.Code {
|
||||||
|
case 404:
|
||||||
|
err = fmt.Errorf("please check if there're any Jenkins plugins issues exist")
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("please check if Jenkins is running well")
|
||||||
|
}
|
||||||
|
klog.Errorf("API '%s' request response code is '%d'", p.Path, jErr.Code)
|
||||||
|
} else {
|
||||||
|
err = fmt.Errorf("unknow errors happend when coumunicate with Jenkins")
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
count, err := p.searchPipelineCount()
|
count, err := p.searchPipelineCount()
|
||||||
|
|||||||
Reference in New Issue
Block a user