How to use the request-promise-core/errors.TransformError 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
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;
});

// The following errors originate from promise-core and it's dependents.
// Give them an errorType for consistency.
original.StatusCodeError.prototype.errorType = 5;
original.TransformError.prototype.errorType = 6;

// This replaces the RequestError for all libraries using request/promise-core
// and prevents silent failure.
Object.defineProperty(original, 'RequestError', {
  configurable: true,
  enumerable: true,
  writable: true,
  value: RequestError
});

// Export our custom errors along with StatusCodeError, etc.
Object.assign(module.exports, original, {
  RequestError: RequestError,
  CaptchaError: CaptchaError,
  ParserError: ParserError,
  CloudflareError: CloudflareError

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