query-registry
Version:
Query the npm registry for packuments, manifests, packages and download counts
43 lines (36 loc) • 1.26 kB
JavaScript
import makeError, { BaseError } from 'make-error';
/**
* `FetchError` represents an error that happened when fetching a URL.
*
* The `instanceof` operator can be used to check for this error.
*/
class FetchError extends BaseError {
constructor(
/** URL originally fetched */
url,
/** Response received */
response) {
super(`fetch: request to ${url} failed with status ${response.statusText}`);
this.url = void 0;
this.response = void 0;
this.url = url;
this.response = response;
}
}
/**
* `InvalidPackageNameError` is thrown when the name of a package
* is not valid according to the npm registry naming rules.
*
* The `instanceof` operator can be used to check for this error.
*
* @see {@link https://www.npmjs.com/package/validate-npm-package-name}
*/
const InvalidPackageNameError = /*#__PURE__*/makeError('InvalidPackageNameError');
/**
* `InvalidPackageVersionError` is thrown when a package's version does not exist.
*
* The `instanceof` operator can be used to check for this error.
*/
const InvalidPackageVersionError = /*#__PURE__*/makeError('InvalidPackageVersionError');
export { FetchError, InvalidPackageNameError, InvalidPackageVersionError };
//# sourceMappingURL=errors.esm.js.map