Verbose flag added

This commit is contained in:
Olivier 2016-12-20 09:04:32 -05:00
parent c5811d75b7
commit 020ac7a6fb
No known key found for this signature in database
GPG key ID: 1A9FE7C1DFF65CB0
3 changed files with 48 additions and 1 deletions

12
jkl.go
View file

@ -3,6 +3,7 @@ package jkl
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
@ -14,6 +15,7 @@ import (
"github.com/joho/godotenv"
)
var Verbose *bool
var defaultIssue = &JiraIssue{}
func bootHttpClient() {
@ -68,6 +70,16 @@ func List(jql string) ([]*JiraIssue, error) {
fmt.Println(err)
return nil, err
}
if resp.StatusCode >= 400 {
fmt.Println("Status code:", resp.StatusCode)
fmt.Println("Response:")
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
fmt.Println(string(b))
return nil, errors.New("Some http error happened.")
}
dec := json.NewDecoder(resp.Body)
var issues = &Search{}
err = dec.Decode(issues)