@aws-amplify/storage
Version:
Storage category of aws-amplify
34 lines (32 loc) • 1.29 kB
JavaScript
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCancelError = exports.CanceledError = void 0;
const StorageError_1 = require("./StorageError");
/**
* Internal-only class for CanceledError thrown by XHR handler or multipart upload when cancellation is invoked
* without overwriting behavior.
*
* @internal
*/
class CanceledError extends StorageError_1.StorageError {
constructor(params = {}) {
super({
name: 'CanceledError',
message: 'Upload is canceled by user',
...params,
});
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = CanceledError;
Object.setPrototypeOf(this, CanceledError.prototype);
}
}
exports.CanceledError = CanceledError;
/**
* Check if an error is caused by user calling `cancel()` on a upload/download task. If an overwriting error is
* supplied to `task.cancel(errorOverwrite)`, this function will return `false`.
*/
const isCancelError = (error) => !!error && error instanceof CanceledError;
exports.isCancelError = isCancelError;
//# sourceMappingURL=CanceledError.js.map
;