1 | import makeError, { BaseError } from 'make-error';
|
2 |
|
3 | /**
|
4 | * `FetchError` represents an error that happened when fetching a URL.
|
5 | *
|
6 | * The `instanceof` operator can be used to check for this error.
|
7 | */
|
8 |
|
9 | class FetchError extends BaseError {
|
10 | constructor(
|
11 | /** URL originally fetched */
|
12 | url,
|
13 | /** Response received */
|
14 | response) {
|
15 | super(`fetch: request to ${url} failed with status ${response.statusText}`);
|
16 | this.url = void 0;
|
17 | this.response = void 0;
|
18 | this.url = url;
|
19 | this.response = response;
|
20 | }
|
21 |
|
22 | }
|
23 | /**
|
24 | * `InvalidPackageNameError` is thrown when the name of a package
|
25 | * is not valid according to the npm registry naming rules.
|
26 | *
|
27 | * The `instanceof` operator can be used to check for this error.
|
28 | *
|
29 | * @see {@link https://www.npmjs.com/package/validate-npm-package-name}
|
30 | */
|
31 |
|
32 | const InvalidPackageNameError = /*#__PURE__*/makeError('InvalidPackageNameError');
|
33 | /**
|
34 | * `InvalidPackageVersionError` is thrown when a package's version does not exist.
|
35 | *
|
36 | * The `instanceof` operator can be used to check for this error.
|
37 | */
|
38 |
|
39 | const InvalidPackageVersionError = /*#__PURE__*/makeError('InvalidPackageVersionError');
|
40 |
|
41 | export { FetchError, InvalidPackageNameError, InvalidPackageVersionError };
|
42 | //# sourceMappingURL=errors.esm.js.map
|