Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: rename StorageNotFoundException #4770

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ part 'network_exception.dart';
part 'push/push_notification_exception.dart';
part 'storage/access_denied_exception.dart';
part 'storage/http_status_exception.dart';
part 'storage/key_not_found_exception.dart';
part 'storage/local_file_not_found_exception.dart';
part 'storage/not_found_exception.dart';
part 'storage/operation_canceled_exception.dart';
part 'storage/path_validation_exception.dart';
part 'storage/storage_exception.dart';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

part of '../amplify_exception.dart';

/// {@template amplify_core.storage.not_found_exception}
/// Exception thrown when the item is not found in the storage service.
/// {@endtemplate}
class StorageNotFoundException extends StorageException {
/// {@macro amplify_core.storage.not_found_exception}
const StorageNotFoundException(
super.message, {
super.recoverySuggestion,
super.underlyingException,
});

@override
String get runtimeTypeName => 'StorageNotFoundException';
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export '../exception/amplify_exception.dart'
StorageException,
StorageAccessDeniedException,
StorageHttpStatusException,
StorageKeyNotFoundException,
StorageNotFoundException,
StorageLocalFileNotFoundException,
StorageOperationCanceledException,
NetworkException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void main() {
source: const StoragePath.fromString('public/non-existent-path'),
destination: const StoragePath.fromString('public/foo'),
).result,
throwsA(isA<StorageKeyNotFoundException>()),
throwsA(isA<StorageNotFoundException>()),
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void main() {
() => Amplify.Storage.getProperties(
path: const StoragePath.fromString('public/not-existent-path'),
).result,
throwsA(isA<StorageKeyNotFoundException>()),
throwsA(isA<StorageNotFoundException>()),
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void main() {
),
),
).result,
throwsA(isA<StorageKeyNotFoundException>()),
throwsA(isA<StorageNotFoundException>()),
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import 'package:amplify_core/amplify_core.dart';
import 'package:amplify_storage_s3/amplify_storage_s3.dart';
import 'package:amplify_storage_s3_example/amplifyconfiguration.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

Expand Down Expand Up @@ -40,8 +39,6 @@ void main() {
).result;
expect(downloadResult.bytes, data);
},
// TODO(Jordan-Nelson): Resolve bug with `AWSFile.fromData` on web.
skip: kIsWeb,
);

testWidgets('from path', (_) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Future<bool> objectExists(StoragePath path) async {
try {
await Amplify.Storage.getProperties(path: path).result;
return true;
} on StorageKeyNotFoundException {
} on StorageNotFoundException {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import 'package:amplify_storage_s3_dart/src/sdk/s3.dart' as s3;
import 'package:meta/meta.dart';
import 'package:smithy/smithy.dart' as smithy;

const _keyNotFoundRecoveryMessage =
'Ensure that correct StoragePath is provided.';
const _notFoundRecoveryMessage = 'Ensure that correct StoragePath is provided.';
const _httpErrorRecoveryMessage =
'HTTP error returned from service, review the `underlyingException` for details.';

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

/// Extension of [s3.NoSuchKey] to add util methods.
extension NoSuchKeyToStorageKeyNotFoundException on s3.NoSuchKey {
/// Creates a [StorageKeyNotFoundException] with the [s3.NoSuchKey] as the
/// Creates a [StorageNotFoundException] with the [s3.NoSuchKey] as the
/// underlying exception.
StorageKeyNotFoundException toStorageKeyNotFoundException() {
return StorageKeyNotFoundException(
StorageNotFoundException toStorageNotFoundException() {
return StorageNotFoundException(
'Cannot find the item specified by the provided path.',
recoverySuggestion: _keyNotFoundRecoveryMessage,
recoverySuggestion: _notFoundRecoveryMessage,
underlyingException: this,
);
}
Expand Down Expand Up @@ -64,9 +63,9 @@ extension UnknownSmithyHttpExceptionToStorageException
underlyingException: this,
);
} else if (statusCode == 404) {
return StorageKeyNotFoundException(
return StorageNotFoundException(
'Cannot find the item specified by the provided path.',
recoverySuggestion: _keyNotFoundRecoveryMessage,
recoverySuggestion: _notFoundRecoveryMessage,
underlyingException: this,
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class S3DownloadTask {
throw error.toStorageException();
} on s3.NoSuchKey catch (error) {
// 404 error is wrapped by s3.NoSuchKey for getObject :/
throw error.toStorageKeyNotFoundException();
throw error.toStorageNotFoundException();
} on AWSHttpException catch (error) {
throw error.toNetworkException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void main() {
});

test(
'should throw StorageKeyNotFoundException when UnknownSmithyHttpException'
'should throw StorageNotFoundException when UnknownSmithyHttpException'
' with status code 404 returned from service', () async {
const testOptions = StorageGetPropertiesOptions();
const testUnknownException = UnknownSmithyHttpException(
Expand All @@ -484,7 +484,7 @@ void main() {
path: const StoragePath.fromString('a key'),
options: testOptions,
),
throwsA(isA<StorageKeyNotFoundException>()),
throwsA(isA<StorageNotFoundException>()),
);
});

Expand Down Expand Up @@ -668,7 +668,7 @@ void main() {
path: testPath,
options: testOptions,
),
throwsA(isA<StorageKeyNotFoundException>()),
throwsA(isA<StorageNotFoundException>()),
);

final capturedRequest = verify(
Expand Down Expand Up @@ -707,7 +707,7 @@ void main() {
path: testPath,
options: testOptions,
),
throwsA(isA<StorageKeyNotFoundException>()),
throwsA(isA<StorageNotFoundException>()),
);

final capturedRequest = verify(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ void main() {
exceptionTypeMatcher: isA<StorageHttpStatusException>(),
),
DownloadTaskExceptionConversionTestItem(
description: 'it should complete with a StorageKeyNotFoundException',
description: 'it should complete with a StorageNotFoundException',
originalException: NoSuchKey(),
exceptionTypeMatcher: isA<StorageKeyNotFoundException>(),
exceptionTypeMatcher: isA<StorageNotFoundException>(),
),
DownloadTaskExceptionConversionTestItem(
description: 'it should complete with a NetworkException',
Expand Down
Loading