Skip to content

Commit

Permalink
[revert] Re-add try/catch and make note of implications for #28.
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Feb 13, 2020
1 parent 995d60b commit dba742f
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions src/jira-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,23 @@ async function makeQuery({ jql, selector = (results) => results.total } = {}) {
const uri = makeJiraUri({ uri: 'api/2/search' });
debug.http(`POST ${uri}`);

// TODO: move to fetch from rp
const response = await rp(Object.assign({}, opts, {
method: 'POST',
uri,
body: {
jql,
startAt: 0,
maxResults: 10000,
fields: ['summary', 'status', 'assignee', 'description', points],
expand: ['schema', 'names']
}
}));

return selector(response);
try {
// TODO: move to fetch from rp
const response = await rp(Object.assign({}, opts, {
method: 'POST',
uri,
body: {
jql,
startAt: 0,
maxResults: 10000,
fields: ['summary', 'status', 'assignee', 'description', points],
expand: ['schema', 'names']
}
}));
return selector(response);
} catch (err) {
throw err;
}
}

async function makeGetRequest(url, api = 'agile/1.0', options = {}) {
Expand All @@ -96,19 +99,32 @@ async function makeGetRequest(url, api = 'agile/1.0', options = {}) {

debug.http(`GET ${uri}`, fullOpts);

return await rp(fullOpts);
try {
return await rp(fullOpts);
} catch (err) {
//
// TODO [#28]: Check x-seraph-loginreason and x-authentication-denied-reason headers
// to see if a user is hellban from JIRA.
// console.dir(err.response.headers);
//
throw err;
}
}

async function makePutRequest(url, api = 'agile/1.0', data = {}) {
const opts = await getRequestOptions();
const uri = makeJiraUri({ uri: `${api}/${url}` });
debug.http(`PUT ${uri}`);

return await rp(Object.assign({}, opts, {
method: 'PUT',
uri,
body: data
}));
try {
return await rp(Object.assign({}, opts, {
method: 'PUT',
uri,
body: data
}));
} catch (err) {
throw err;
}
}

module.exports = {
Expand Down

0 comments on commit dba742f

Please sign in to comment.