Skip Menu |

This queue is for tickets about the JIRA-Client-Automated CPAN distribution.

Report information
The Basics
Id: 96887
Status: resolved
Priority: 0/
Queue: JIRA-Client-Automated

People
Owner: FRIMICC [...] cpan.org
Requestors: TIMB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 1.1



Subject: Error messages don't include the content of the response, which contains important information
For example, currently an error report might say: Error creating new JIRA issue Foo test 400 Bad Request but if the content was included in would say: Error creating new JIRA issue Foo test 400 Bad Request {"errorMessages":[],"errors":{"project":"project is required"}} which is much more helpful. We could bike shed the formatting, but just reporting the jaw json seems fine as a minimum: die "Error creating new JIRA issue $fields->{summary} " . $response->status_line() . " " . $response->content; I'd also suggest: a) add a _make_request($request) method that does the authorization_basic call, the $self->{_ua}->request($request) call and the is_success check. b) refactor the code to use _make_request in all the methods (9!) that currently duplicate that logic c) add an error_response_handler attribute that's a code ref that default to the die shown above d) use that in _make_request so now apps can provide their own error handling I could send you a patch for the above if you'd like. Or, even better, a pull request if you put the code on github.
That is a great idea! Error handling hasn't been an issue at my office because our JIRA is practically unchanging, so I haven't put a lot of effort into it yet. The code is on GitHub in https://github.com/frimicc/jira-client-automated . If you have the time to make this change, either the easy version or the callback version, that'd be awesome. I won't be able to get to it for several weeks otherwise. Thanks! -- Michael On Wed Jul 02 08:48:18 2014, TIMB wrote: Show quoted text
> For example, currently an error report might say: > > Error creating new JIRA issue Foo test 400 Bad Request > > but if the content was included in would say: > > Error creating new JIRA issue Foo test 400 Bad Request > {"errorMessages":[],"errors":{"project":"project is required"}} > > which is much more helpful. > > We could bike shed the formatting, but just reporting the jaw json > seems fine as a minimum: > > die "Error creating new JIRA issue $fields->{summary} " . $response-
> >status_line() . " " . $response->content;
> > I'd also suggest: > a) add a _make_request($request) method that does the > authorization_basic call, the $self->{_ua}->request($request) call and > the is_success check. > b) refactor the code to use _make_request in all the methods (9!) that > currently duplicate that logic > c) add an error_response_handler attribute that's a code ref that > default to the die shown above > d) use that in _make_request so now apps can provide their own error > handling > > I could send you a patch for the above if you'd like. Or, even better, > a pull request if you put the code on github.
Thanks for the great patches! I had been trying to put all the requests together into a single method, for convenience, but hadn't gotten as far as to build in a callback for the one call that's different. I've merged in your patches and released 1.1 containing all your fixes. Please let me know if you have more problems or suggestions for the module. -- Michael On Wed Jul 02 08:48:18 2014, TIMB wrote: Show quoted text
> For example, currently an error report might say: > > Error creating new JIRA issue Foo test 400 Bad Request > > but if the content was included in would say: > > Error creating new JIRA issue Foo test 400 Bad Request > {"errorMessages":[],"errors":{"project":"project is required"}} > > which is much more helpful. > > We could bike shed the formatting, but just reporting the jaw json > seems fine as a minimum: > > die "Error creating new JIRA issue $fields->{summary} " . $response-
> >status_line() . " " . $response->content;
> > I'd also suggest: > a) add a _make_request($request) method that does the > authorization_basic call, the $self->{_ua}->request($request) call and > the is_success check. > b) refactor the code to use _make_request in all the methods (9!) that > currently duplicate that logic > c) add an error_response_handler attribute that's a code ref that > default to the die shown above > d) use that in _make_request so now apps can provide their own error > handling > > I could send you a patch for the above if you'd like. Or, even better, > a pull request if you put the code on github.