How to use @octokit/request-error - 10 common examples

To help you get started, we’ve selected a few @octokit/request-error examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maierj / fastlane-action / node_modules / @octokit / request / dist-src / fetch-wrapper.js View on Github external
.then(response => {
        url = response.url;
        status = response.status;
        for (const keyAndValue of response.headers) {
            headers[keyAndValue[0]] = keyAndValue[1];
        }
        if (status === 204 || status === 205) {
            return;
        }
        // GitHub API returns 200 for HEAD requsets
        if (requestOptions.method === "HEAD") {
            if (status < 400) {
                return;
            }
            throw new RequestError(response.statusText, status, {
                headers,
                request: requestOptions
            });
        }
        if (status === 304) {
            throw new RequestError("Not modified", status, {
                headers,
                request: requestOptions
            });
        }
        if (status >= 400) {
            return response
                .text()
                .then(message => {
                const error = new RequestError(message, status, {
                    headers,
github maierj / fastlane-action / node_modules / @octokit / request / dist-src / fetch-wrapper.js View on Github external
}
        if (status === 204 || status === 205) {
            return;
        }
        // GitHub API returns 200 for HEAD requsets
        if (requestOptions.method === "HEAD") {
            if (status < 400) {
                return;
            }
            throw new RequestError(response.statusText, status, {
                headers,
                request: requestOptions
            });
        }
        if (status === 304) {
            throw new RequestError("Not modified", status, {
                headers,
                request: requestOptions
            });
        }
        if (status >= 400) {
            return response
                .text()
                .then(message => {
                const error = new RequestError(message, status, {
                    headers,
                    request: requestOptions
                });
                try {
                    let responseBody = JSON.parse(error.message);
                    Object.assign(error, responseBody);
                    let errors = responseBody.errors;
github newrelic / newrelic-ruby-agent / .github / actions / build-ruby / node_modules / @octokit / request / dist-web / index.js View on Github external
.then((response) => {
        url = response.url;
        status = response.status;
        for (const keyAndValue of response.headers) {
            headers[keyAndValue[0]] = keyAndValue[1];
        }
        if (status === 204 || status === 205) {
            return;
        }
        // GitHub API returns 200 for HEAD requests
        if (requestOptions.method === "HEAD") {
            if (status < 400) {
                return;
            }
            throw new RequestError(response.statusText, status, {
                headers,
                request: requestOptions,
            });
        }
        if (status === 304) {
            throw new RequestError("Not modified", status, {
                headers,
                request: requestOptions,
            });
        }
        if (status >= 400) {
            return response
                .text()
                .then((message) => {
                const error = new RequestError(message, status, {
                    headers,
github maierj / fastlane-action / node_modules / @octokit / request / dist-src / fetch-wrapper.js View on Github external
.then(message => {
                const error = new RequestError(message, status, {
                    headers,
                    request: requestOptions
                });
                try {
                    let responseBody = JSON.parse(error.message);
                    Object.assign(error, responseBody);
                    let errors = responseBody.errors;
                    // Assumption `errors` would always be in Array Fotmat
                    error.message =
                        error.message + ": " + errors.map(JSON.stringify).join(", ");
                }
                catch (e) {
                    // ignore, see octokit/rest.js#684
                }
                throw error;
            });
github svenstaro / upload-release-action / node_modules / @octokit / request / dist-node / index.js View on Github external
} // GitHub API returns 200 for HEAD requsets


    if (requestOptions.method === "HEAD") {
      if (status < 400) {
        return;
      }

      throw new requestError.RequestError(response.statusText, status, {
        headers,
        request: requestOptions
      });
    }

    if (status === 304) {
      throw new requestError.RequestError("Not modified", status, {
        headers,
        request: requestOptions
      });
    }

    if (status >= 400) {
      return response.text().then(message => {
        const error = new requestError.RequestError(message, status, {
          headers,
          request: requestOptions
        });

        try {
          Object.assign(error, JSON.parse(error.message));
        } catch (e) {// ignore, see octokit/rest.js#684
        }
github svenstaro / upload-release-action / node_modules / @octokit / request / dist-web / index.js View on Github external
.then(response => {
        url = response.url;
        status = response.status;
        for (const keyAndValue of response.headers) {
            headers[keyAndValue[0]] = keyAndValue[1];
        }
        if (status === 204 || status === 205) {
            return;
        }
        // GitHub API returns 200 for HEAD requsets
        if (requestOptions.method === "HEAD") {
            if (status < 400) {
                return;
            }
            throw new RequestError(response.statusText, status, {
                headers,
                request: requestOptions
            });
        }
        if (status === 304) {
            throw new RequestError("Not modified", status, {
                headers,
                request: requestOptions
            });
        }
        if (status >= 400) {
            return response
                .text()
                .then(message => {
                const error = new RequestError(message, status, {
                    headers,
github Azure / dev-spaces / actions / add-review-url / node_modules / @octokit / request / dist-src / fetch-wrapper.js View on Github external
.then(message => {
                const error = new RequestError(message, status, {
                    headers,
                    request: requestOptions
                });
                try {
                    let responseBody = JSON.parse(error.message);
                    Object.assign(error, responseBody);
                    let errors = responseBody.errors;
                    // Assumption `errors` would always be in Array Fotmat
                    error.message =
                        error.message + ": " + errors.map(JSON.stringify).join(", ");
                }
                catch (e) {
                    // ignore, see octokit/rest.js#684
                }
                throw error;
            });
github release-it / release-it / test / github.js View on Github external
test('should handle octokit client error (without retries)', async t => {
  const github = factory(GitHub, { options: { github: { tokenRef, remoteUrl, host } } });
  const stub = sinon.stub(github.client.repos, 'createRelease');
  stub.throws(new RequestError('Not found', 404, { request: { url: '', headers: {} } }));
  interceptAuthentication();
  interceptCollaborator();

  await t.throwsAsync(runTasks(github), { instanceOf: GitHubClientError, message: '404 (Not found)' });

  t.is(stub.callCount, 1);
  stub.restore();
});
github Azure / dev-spaces / actions / add-review-url / node_modules / @octokit / request / dist-node / index.js View on Github external
}).catch(error => {
    if (error instanceof requestError.RequestError) {
      throw error;
    }

    throw new requestError.RequestError(error.message, 500, {
      headers,
      request: requestOptions
    });
  });
}
github Azure / dev-spaces / actions / add-review-url / node_modules / @octokit / request / dist-web / index.js View on Github external
.catch(error => {
        if (error instanceof RequestError) {
            throw error;
        }
        throw new RequestError(error.message, 500, {
            headers,
            request: requestOptions
        });
    });
}

@octokit/request-error

Error class for Octokit request errors

MIT
Latest version published 2 months ago

Package Health Score

86 / 100
Full package analysis

Popular @octokit/request-error functions