Skip to content

Commit 292bcec

Browse files
chore!: rename StorageNotFoundException (#4770)
* chore!: rename `StorageNotFoundException` * chore: remove skip test for web
1 parent d961106 commit 292bcec

File tree

13 files changed

+39
-43
lines changed

13 files changed

+39
-43
lines changed

packages/amplify_core/lib/src/types/exception/amplify_exception.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ part 'network_exception.dart';
2121
part 'push/push_notification_exception.dart';
2222
part 'storage/access_denied_exception.dart';
2323
part 'storage/http_status_exception.dart';
24-
part 'storage/key_not_found_exception.dart';
2524
part 'storage/local_file_not_found_exception.dart';
25+
part 'storage/not_found_exception.dart';
2626
part 'storage/operation_canceled_exception.dart';
2727
part 'storage/path_validation_exception.dart';
2828
part 'storage/storage_exception.dart';

packages/amplify_core/lib/src/types/exception/storage/key_not_found_exception.dart

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
part of '../amplify_exception.dart';
5+
6+
/// {@template amplify_core.storage.not_found_exception}
7+
/// Exception thrown when the item is not found in the storage service.
8+
/// {@endtemplate}
9+
class StorageNotFoundException extends StorageException {
10+
/// {@macro amplify_core.storage.not_found_exception}
11+
const StorageNotFoundException(
12+
super.message, {
13+
super.recoverySuggestion,
14+
super.underlyingException,
15+
});
16+
17+
@override
18+
String get runtimeTypeName => 'StorageNotFoundException';
19+
}

packages/amplify_core/lib/src/types/storage/storage_types.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export '../exception/amplify_exception.dart'
66
StorageException,
77
StorageAccessDeniedException,
88
StorageHttpStatusException,
9-
StorageKeyNotFoundException,
9+
StorageNotFoundException,
1010
StorageLocalFileNotFoundException,
1111
StorageOperationCanceledException,
1212
NetworkException,

packages/storage/amplify_storage_s3/example/integration_test/copy_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void main() {
114114
source: const StoragePath.fromString('public/non-existent-path'),
115115
destination: const StoragePath.fromString('public/foo'),
116116
).result,
117-
throwsA(isA<StorageKeyNotFoundException>()),
117+
throwsA(isA<StorageNotFoundException>()),
118118
);
119119
});
120120
});

packages/storage/amplify_storage_s3/example/integration_test/get_properties_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void main() {
7575
() => Amplify.Storage.getProperties(
7676
path: const StoragePath.fromString('public/not-existent-path'),
7777
).result,
78-
throwsA(isA<StorageKeyNotFoundException>()),
78+
throwsA(isA<StorageNotFoundException>()),
7979
);
8080
});
8181
});

packages/storage/amplify_storage_s3/example/integration_test/get_url_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void main() {
140140
),
141141
),
142142
).result,
143-
throwsA(isA<StorageKeyNotFoundException>()),
143+
throwsA(isA<StorageNotFoundException>()),
144144
);
145145
});
146146

packages/storage/amplify_storage_s3/example/integration_test/upload_file_test.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import 'package:amplify_core/amplify_core.dart';
55
import 'package:amplify_storage_s3/amplify_storage_s3.dart';
66
import 'package:amplify_storage_s3_example/amplifyconfiguration.dart';
7-
import 'package:flutter/foundation.dart';
87
import 'package:flutter_test/flutter_test.dart';
98
import 'package:integration_test/integration_test.dart';
109

@@ -40,8 +39,6 @@ void main() {
4039
).result;
4140
expect(downloadResult.bytes, data);
4241
},
43-
// TODO(Jordan-Nelson): Resolve bug with `AWSFile.fromData` on web.
44-
skip: kIsWeb,
4542
);
4643

4744
testWidgets('from path', (_) async {

packages/storage/amplify_storage_s3/example/integration_test/utils/object_exists.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Future<bool> objectExists(StoragePath path) async {
55
try {
66
await Amplify.Storage.getProperties(path: path).result;
77
return true;
8-
} on StorageKeyNotFoundException {
8+
} on StorageNotFoundException {
99
return false;
1010
}
1111
}

packages/storage/amplify_storage_s3_dart/lib/src/exception/s3_storage_exception.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import 'package:amplify_storage_s3_dart/src/sdk/s3.dart' as s3;
77
import 'package:meta/meta.dart';
88
import 'package:smithy/smithy.dart' as smithy;
99

10-
const _keyNotFoundRecoveryMessage =
11-
'Ensure that correct StoragePath is provided.';
10+
const _notFoundRecoveryMessage = 'Ensure that correct StoragePath is provided.';
1211
const _httpErrorRecoveryMessage =
1312
'HTTP error returned from service, review the `underlyingException` for details.';
1413

@@ -29,12 +28,12 @@ final accelerateEndpointUnusable = ConfigurationError(
2928

3029
/// Extension of [s3.NoSuchKey] to add util methods.
3130
extension NoSuchKeyToStorageKeyNotFoundException on s3.NoSuchKey {
32-
/// Creates a [StorageKeyNotFoundException] with the [s3.NoSuchKey] as the
31+
/// Creates a [StorageNotFoundException] with the [s3.NoSuchKey] as the
3332
/// underlying exception.
34-
StorageKeyNotFoundException toStorageKeyNotFoundException() {
35-
return StorageKeyNotFoundException(
33+
StorageNotFoundException toStorageNotFoundException() {
34+
return StorageNotFoundException(
3635
'Cannot find the item specified by the provided path.',
37-
recoverySuggestion: _keyNotFoundRecoveryMessage,
36+
recoverySuggestion: _notFoundRecoveryMessage,
3837
underlyingException: this,
3938
);
4039
}
@@ -64,9 +63,9 @@ extension UnknownSmithyHttpExceptionToStorageException
6463
underlyingException: this,
6564
);
6665
} else if (statusCode == 404) {
67-
return StorageKeyNotFoundException(
66+
return StorageNotFoundException(
6867
'Cannot find the item specified by the provided path.',
69-
recoverySuggestion: _keyNotFoundRecoveryMessage,
68+
recoverySuggestion: _notFoundRecoveryMessage,
7069
underlyingException: this,
7170
);
7271
} else {

packages/storage/amplify_storage_s3_dart/lib/src/storage_s3_service/service/task/s3_download_task.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class S3DownloadTask {
355355
throw error.toStorageException();
356356
} on s3.NoSuchKey catch (error) {
357357
// 404 error is wrapped by s3.NoSuchKey for getObject :/
358-
throw error.toStorageKeyNotFoundException();
358+
throw error.toStorageNotFoundException();
359359
} on AWSHttpException catch (error) {
360360
throw error.toNetworkException();
361361
}

packages/storage/amplify_storage_s3_dart/test/storage_s3_service/storage_s3_service_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ void main() {
465465
});
466466

467467
test(
468-
'should throw StorageKeyNotFoundException when UnknownSmithyHttpException'
468+
'should throw StorageNotFoundException when UnknownSmithyHttpException'
469469
' with status code 404 returned from service', () async {
470470
const testOptions = StorageGetPropertiesOptions();
471471
const testUnknownException = UnknownSmithyHttpException(
@@ -484,7 +484,7 @@ void main() {
484484
path: const StoragePath.fromString('a key'),
485485
options: testOptions,
486486
),
487-
throwsA(isA<StorageKeyNotFoundException>()),
487+
throwsA(isA<StorageNotFoundException>()),
488488
);
489489
});
490490

@@ -668,7 +668,7 @@ void main() {
668668
path: testPath,
669669
options: testOptions,
670670
),
671-
throwsA(isA<StorageKeyNotFoundException>()),
671+
throwsA(isA<StorageNotFoundException>()),
672672
);
673673

674674
final capturedRequest = verify(
@@ -707,7 +707,7 @@ void main() {
707707
path: testPath,
708708
options: testOptions,
709709
),
710-
throwsA(isA<StorageKeyNotFoundException>()),
710+
throwsA(isA<StorageNotFoundException>()),
711711
);
712712

713713
final capturedRequest = verify(

packages/storage/amplify_storage_s3_dart/test/storage_s3_service/task/s3_download_task_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ void main() {
430430
exceptionTypeMatcher: isA<StorageHttpStatusException>(),
431431
),
432432
DownloadTaskExceptionConversionTestItem(
433-
description: 'it should complete with a StorageKeyNotFoundException',
433+
description: 'it should complete with a StorageNotFoundException',
434434
originalException: NoSuchKey(),
435-
exceptionTypeMatcher: isA<StorageKeyNotFoundException>(),
435+
exceptionTypeMatcher: isA<StorageNotFoundException>(),
436436
),
437437
DownloadTaskExceptionConversionTestItem(
438438
description: 'it should complete with a NetworkException',

0 commit comments

Comments
 (0)