mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-01-20 02:59:58 +02:00
Adding jira.Error to all functions that can return a jira specific JSON error
This commit is contained in:
parent
5655cb856a
commit
2eaa9b17ce
17
board.go
17
board.go
@ -75,7 +75,8 @@ func (s *BoardService) GetAllBoards(opt *BoardListOptions) (*BoardsList, *Respon
|
||||
boards := new(BoardsList)
|
||||
resp, err := s.client.Do(req, boards)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
return boards, resp, err
|
||||
@ -95,8 +96,10 @@ func (s *BoardService) GetBoard(boardID int) (*Board, *Response, error) {
|
||||
board := new(Board)
|
||||
resp, err := s.client.Do(req, board)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
return board, resp, nil
|
||||
}
|
||||
|
||||
@ -118,7 +121,8 @@ func (s *BoardService) CreateBoard(board *Board) (*Board, *Response, error) {
|
||||
responseBoard := new(Board)
|
||||
resp, err := s.client.Do(req, responseBoard)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
return responseBoard, resp, nil
|
||||
@ -135,6 +139,9 @@ func (s *BoardService) DeleteBoard(boardID int) (*Board, *Response, error) {
|
||||
}
|
||||
|
||||
resp, err := s.client.Do(req, nil)
|
||||
if err != nil {
|
||||
err = NewJiraError(resp, err)
|
||||
}
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
@ -151,5 +158,9 @@ func (s *BoardService) GetAllSprints(boardID string) ([]Sprint, *Response, error
|
||||
|
||||
result := new(sprintsResult)
|
||||
resp, err := s.client.Do(req, result)
|
||||
if err != nil {
|
||||
err = NewJiraError(resp, err)
|
||||
}
|
||||
|
||||
return result.Sprints, resp, err
|
||||
}
|
||||
|
29
issue.go
29
issue.go
@ -383,7 +383,8 @@ func (s *IssueService) DownloadAttachment(attachmentID string) (*Response, error
|
||||
|
||||
resp, err := s.client.Do(req, nil)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return resp, jerr
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
@ -420,7 +421,8 @@ func (s *IssueService) PostAttachment(attachmentID string, r io.Reader, attachme
|
||||
attachment := new([]Attachment)
|
||||
resp, err := s.client.Do(req, attachment)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
return attachment, resp, nil
|
||||
@ -441,7 +443,8 @@ func (s *IssueService) Create(issue *Issue) (*Issue, *Response, error) {
|
||||
responseIssue := new(Issue)
|
||||
resp, err := s.client.Do(req, responseIssue)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
return responseIssue, resp, nil
|
||||
@ -460,7 +463,8 @@ func (s *IssueService) AddComment(issueID string, comment *Comment) (*Comment, *
|
||||
responseComment := new(Comment)
|
||||
resp, err := s.client.Do(req, responseComment)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
return responseComment, resp, nil
|
||||
@ -477,6 +481,10 @@ func (s *IssueService) AddLink(issueLink *IssueLink) (*Response, error) {
|
||||
}
|
||||
|
||||
resp, err := s.client.Do(req, nil)
|
||||
if err != nil {
|
||||
err = NewJiraError(resp, err)
|
||||
}
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@ -499,6 +507,9 @@ func (s *IssueService) Search(jql string, options *SearchOptions) ([]Issue, *Res
|
||||
|
||||
v := new(searchResult)
|
||||
resp, err := s.client.Do(req, v)
|
||||
if err != nil {
|
||||
err = NewJiraError(resp, err)
|
||||
}
|
||||
return v.Issues, resp, err
|
||||
}
|
||||
|
||||
@ -513,7 +524,8 @@ func (s *IssueService) GetCustomFields(issueID string) (CustomFields, *Response,
|
||||
issue := new(map[string]interface{})
|
||||
resp, err := s.client.Do(req, issue)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
m := *issue
|
||||
@ -546,6 +558,9 @@ func (s *IssueService) GetTransitions(id string) ([]Transition, *Response, error
|
||||
|
||||
result := new(transitionResult)
|
||||
resp, err := s.client.Do(req, result)
|
||||
if err != nil {
|
||||
err = NewJiraError(resp, err)
|
||||
}
|
||||
return result.Transitions, resp, err
|
||||
}
|
||||
|
||||
@ -568,8 +583,8 @@ func (s *IssueService) DoTransition(ticketID, transitionID string) (*Response, e
|
||||
|
||||
resp, err := s.client.Do(req, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
err = NewJiraError(resp, err)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
return resp, err
|
||||
}
|
||||
|
10
project.go
10
project.go
@ -62,7 +62,7 @@ type Version struct {
|
||||
Released bool `json:"released"`
|
||||
ReleaseDate string `json:"releaseDate"`
|
||||
UserReleaseDate string `json:"userReleaseDate"`
|
||||
ProjectID int `json:"projectId"` // Unlike other IDs, this is returned as a number
|
||||
ProjectID int `json:"projectId"` // Unlike other IDs, this is returned as a number
|
||||
}
|
||||
|
||||
// ProjectComponent represents a single component of a project
|
||||
@ -94,8 +94,10 @@ func (s *ProjectService) GetList() (*ProjectList, *Response, error) {
|
||||
projectList := new(ProjectList)
|
||||
resp, err := s.client.Do(req, projectList)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
return projectList, resp, nil
|
||||
}
|
||||
|
||||
@ -114,7 +116,9 @@ func (s *ProjectService) Get(projectID string) (*Project, *Response, error) {
|
||||
project := new(Project)
|
||||
resp, err := s.client.Do(req, project)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
return project, resp, nil
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ func (s *SprintService) MoveIssuesToSprint(sprintID int, issueIDs []string) (*Re
|
||||
}
|
||||
|
||||
resp, err := s.client.Do(req, nil)
|
||||
if err != nil {
|
||||
err = NewJiraError(resp, err)
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
@ -56,5 +59,9 @@ func (s *SprintService) GetIssuesForSprint(sprintID int) ([]Issue, *Response, er
|
||||
|
||||
result := new(IssuesInSprintResult)
|
||||
resp, err := s.client.Do(req, result)
|
||||
if err != nil {
|
||||
err = NewJiraError(resp, err)
|
||||
}
|
||||
|
||||
return result.Issues, resp, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user