How to use the request-promise-core/errors.RequestError function in request-promise-core

To help you get started, we’ve selected a few request-promise-core 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 codemanki / cloudscraper / errors.js View on Github external
1004: 'Host Not Configured to Serve Web Traffic',
  1005: 'Access Denied: IP of banned ASN/ISP',
  1010: 'The owner of this website has banned your access based on your browser\'s signature',
  1011: 'Access Denied (Hotlinking Denied)',
  1012: 'Access Denied',
  1013: 'HTTP hostname and TLS SNI hostname mismatch',
  1016: 'Origin DNS error',
  1018: 'Domain is misconfigured',
  1020: 'Access Denied (Custom Firewall Rules)'
};

ERROR_CODES[1006] =
    ERROR_CODES[1007] =
        ERROR_CODES[1008] = 'Access Denied: Your IP address has been banned';

const OriginalError = original.RequestError;

const RequestError = create('RequestError', 0);
const CaptchaError = create('CaptchaError', 1);

// errorType 4 is a CloudflareError so this constructor is reused.
const CloudflareError = create('CloudflareError', 2, function (error) {
  if (!isNaN(error.cause)) {
    const description = ERROR_CODES[error.cause] || http.STATUS_CODES[error.cause];
    if (description) {
      error.message = error.cause + ', ' + description;
    }
  }
});

const ParserError = create('ParserError', 3, function (error) {
  error.message = BUG_REPORT + error.message;

request-promise-core

Core Promise support implementation for the simplified HTTP request client 'request'.

ISC
Latest version published 4 years ago

Package Health Score

65 / 100
Full package analysis