Skip to content

Commit 3b693d1

Browse files
authored
Merge pull request #3 from drakeapps/master
Improve error logging by passing back JIRA response
2 parents e452dc8 + ee89772 commit 3b693d1

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

package/main.tcl

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ namespace eval ::jira {
240240
# parray result
241241
return 1
242242
} else {
243+
# pass the json response in the result array to improve error handling
244+
array set result [array get json]
243245
return 0
244246
}
245247

@@ -289,6 +291,8 @@ namespace eval ::jira {
289291
array set result [::yajl::json2dict $json(data)]
290292
return 1
291293
} else {
294+
# pass the json response in the result array to improve error handling
295+
array set result [array get json]
292296
return 0
293297
}
294298
}
@@ -348,6 +352,8 @@ namespace eval ::jira {
348352
array set result [::yajl::json2dict $json(data)]
349353
return 1
350354
} else {
355+
# pass the json response in the result array to improve error handling
356+
array set result [array get json]
351357
return 0
352358
}
353359
}
@@ -401,6 +407,8 @@ namespace eval ::jira {
401407
array set result [::yajl::json2dict $json(data)]
402408
return 1
403409
} else {
410+
# pass the json response in the result array to improve error handling
411+
array set result [array get json]
404412
return 0
405413
}
406414
}
@@ -442,6 +450,8 @@ namespace eval ::jira {
442450
array set result [::yajl::json2dict $json(data)]
443451
return 1
444452
} else {
453+
# pass the json response in the result array to improve error handling
454+
array set result [array get json]
445455
return 0
446456
}
447457
}
@@ -483,9 +493,10 @@ namespace eval ::jira {
483493

484494
if {[::jira::raw $url POST json -body $jsonpost]} {
485495
array set result [::yajl::json2dict $json(data)]
486-
# parray result
487496
return 1
488497
} else {
498+
# pass the json response in the result array to improve error handling
499+
array set result [array get json]
489500
return 0
490501
}
491502
} else {
@@ -505,6 +516,8 @@ namespace eval ::jira {
505516
array set result [::yajl::json2dict $json(data)]
506517
return 1
507518
} else {
519+
# pass the json response in the result array to improve error handling
520+
array set result [array get json]
508521
return 0
509522
}
510523
}
@@ -542,6 +555,7 @@ namespace eval ::jira {
542555
return 1
543556
}
544557
} else {
558+
array set result [array get json]
545559
return 0
546560
}
547561
}
@@ -565,9 +579,10 @@ namespace eval ::jira {
565579

566580
if {[::jira::raw $url GET json]} {
567581
array set result [::yajl::json2dict $json(data)]
568-
# parray result
569582
return 1
570583
} else {
584+
# pass the json response in the result array to improve error handling
585+
array set result [array get json]
571586
return 0
572587
}
573588
}
@@ -593,7 +608,6 @@ namespace eval ::jira {
593608
unset -nocomplain project
594609
array set project $p
595610
if {![info exists argarray(key)] || $argarray(key) eq $project(key)} {
596-
# parray project
597611
foreach i $project(issuetypes) {
598612
unset -nocomplain it
599613
array set it $i
@@ -602,9 +616,10 @@ namespace eval ::jira {
602616
}
603617
}
604618

605-
# parray result
606619
return 1
607620
} else {
621+
# pass the json response in the result array to improve error handling
622+
array set result [array get json]
608623
return 0
609624
}
610625

@@ -622,8 +637,6 @@ namespace eval ::jira {
622637
foreach el [::yajl::json2dict $json(data)] {
623638
unset -nocomplain item
624639
array set item $el
625-
#parray item
626-
#puts "-- "
627640
if {[string tolower $name] eq [string tolower $item($field)]} {
628641
return $item(id)
629642
}
@@ -645,9 +658,10 @@ namespace eval ::jira {
645658

646659
if {[::jira::raw $url GET json]} {
647660
array set result [::yajl::json2dict $json(data)]
648-
# parray result
649661
return 1
650662
} else {
663+
# pass the json response in the result array to improve error handling
664+
array set result [array get json]
651665
return 0
652666
}
653667
}
@@ -666,9 +680,10 @@ namespace eval ::jira {
666680

667681
if {[::jira::raw $url GET json]} {
668682
array set result [::yajl::json2dict $json(data)]
669-
# parray result
670683
return 1
671684
} else {
685+
# pass the json response in the result array to improve error handling
686+
array set result [array get json]
672687
return 0
673688
}
674689
}
@@ -682,9 +697,11 @@ namespace eval ::jira {
682697

683698
set url "[::jira::baseurl]/rest/api/2/project/${projectID}/versions"
684699
if {[::jira::raw $url GET json]} {
685-
set result [::yajl::json2dict $json(data)]
700+
array set result [::yajl::json2dict $json(data)]
686701
return 1
687702
} else {
703+
# pass the json response in the result array to improve error handling
704+
array set result [array get json]
688705
return 0
689706
}
690707

@@ -723,9 +740,10 @@ namespace eval ::jira {
723740

724741
if {[::jira::raw $url PUT json -body $jsonpost]} {
725742
array set result [::yajl::json2dict $json(data)]
726-
# parray result
727743
return 1
728744
} else {
745+
# pass the json response in the result array to improve error handling
746+
array set result [array get json]
729747
return 0
730748
}
731749
}

0 commit comments

Comments
 (0)