1 | import { StorageError } from './StorageError.mjs';
|
2 |
|
3 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 | // SPDX-License-Identifier: Apache-2.0
|
5 | /**
|
6 | * Internal-only class for CanceledError thrown by XHR handler or multipart upload when cancellation is invoked
|
7 | * without overwriting behavior.
|
8 | *
|
9 | * @internal
|
10 | */
|
11 | class CanceledError extends StorageError {
|
12 | constructor(params = {}) {
|
13 | super({
|
14 | name: 'CanceledError',
|
15 | message: 'Upload is canceled by user',
|
16 | ...params,
|
17 | });
|
18 | // TODO: Delete the following 2 lines after we change the build target to >= es2015
|
19 | this.constructor = CanceledError;
|
20 | Object.setPrototypeOf(this, CanceledError.prototype);
|
21 | }
|
22 | }
|
23 | /**
|
24 | * Check if an error is caused by user calling `cancel()` on a upload/download task. If an overwriting error is
|
25 | * supplied to `task.cancel(errorOverwrite)`, this function will return `false`.
|
26 | * @param {unknown} error The unknown exception to be checked.
|
27 | * @returns - A boolean indicating if the error was from an upload cancellation
|
28 | */
|
29 | const isCancelError = (error) => !!error && error instanceof CanceledError;
|
30 |
|
31 | export { CanceledError, isCancelError };
|
32 | //# sourceMappingURL=CanceledError.mjs.map
|