This commit is contained in:
David Kale
2020-09-08 13:25:36 -04:00
parent e4246d2b5b
commit 91fcbb0108
4227 changed files with 416837 additions and 457884 deletions

View File

@@ -5,13 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
var request = require('@octokit/request');
var universalUserAgent = require('universal-user-agent');
const VERSION = "4.4.0";
const VERSION = "4.5.4";
class GraphqlError extends Error {
constructor(request, response) {
const message = response.data.errors[0].message;
super(message);
Object.assign(this, response.data);
Object.assign(this, {
headers: response.headers
});
this.name = "GraphqlError";
this.request = request; // Maintains proper stack trace (only available on V8)
@@ -44,7 +47,14 @@ function graphql(request, query, options) {
}, {});
return request(requestOptions).then(response => {
if (response.data.errors) {
const headers = {};
for (const key of Object.keys(response.headers)) {
headers[key] = response.headers[key];
}
throw new GraphqlError(requestOptions, {
headers,
data: response.data
});
}