Skip to content

Commit e6676ec

Browse files
Dillon Nysdnys1
authored andcommitted
chore(core): Sealed exception types
Makes all `AmplifyException` category subtypes sealed.
1 parent a99a358 commit e6676ec

18 files changed

+64
-29
lines changed

packages/amplify_core/lib/src/types/analytics/analytics_types.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
/// Exception Types.
5-
export '../exception/analytics/analytics_exception.dart';
6-
export '../exception/analytics/invalid_event_exception.dart';
5+
export '../exception/amplify_exception.dart'
6+
show
7+
AnalyticsException,
8+
InvalidEventException,
9+
NetworkException,
10+
UnknownException;
711

812
/// API Types.
913
export 'analytics/analytics_event.dart';

packages/amplify_core/lib/src/types/api/api_types.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
// Packages
55
export 'package:retry/retry.dart' show RetryOptions;
66

7-
/// Exceptions
8-
export '../exception/api/api_exception.dart';
9-
export '../exception/api/http_status_exception.dart';
10-
export '../exception/api/operation_exception.dart';
7+
/// Exception Types.
8+
export '../exception/amplify_exception.dart'
9+
show
10+
ApiException,
11+
ApiOperationException,
12+
HttpStatusException,
13+
NetworkException,
14+
UnknownException;
1115
// API Authorization
1216
export 'auth/api_auth_provider.dart';
1317
export 'auth/api_authorization_type.dart';

packages/amplify_core/lib/src/types/auth/auth_types.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
/// Exceptions
5-
export '../exception/amplify_exception.dart';
5+
export '../exception/amplify_exception.dart'
6+
show
7+
AuthException,
8+
InvalidStateException,
9+
AuthNotAuthorizedException,
10+
AuthServiceException,
11+
SessionExpiredException,
12+
SignedOutException,
13+
UserCancelledException,
14+
AuthValidationException,
15+
NetworkException,
16+
UnknownException;
617

718
/// Attributes
819
export 'attribute/auth_next_update_attribute_step.dart';

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
import 'package:amplify_core/amplify_core.dart';
55
import 'package:meta/meta.dart';
66

7+
part 'analytics/analytics_exception.dart';
8+
part 'analytics/invalid_event_exception.dart';
9+
part 'api/api_exception.dart';
10+
part 'api/http_status_exception.dart';
11+
part 'api/operation_exception.dart';
712
part 'auth/auth_exception.dart';
813
part 'auth/invalid_state_exception.dart';
914
part 'auth/not_authorized_exception.dart';
@@ -13,6 +18,13 @@ part 'auth/signed_out_exception.dart';
1318
part 'auth/user_cancelled_exception.dart';
1419
part 'auth/validation_exception.dart';
1520
part 'network_exception.dart';
21+
part 'push/push_notification_exception.dart';
22+
part 'storage/access_denied_exception.dart';
23+
part 'storage/http_status_exception.dart';
24+
part 'storage/key_not_found_exception.dart';
25+
part 'storage/local_file_not_found_exception.dart';
26+
part 'storage/operation_canceled_exception.dart';
27+
part 'storage/storage_exception.dart';
1628
part 'unknown_exception.dart';
1729

1830
/// {@template amplify_core.amplify_exception}

packages/amplify_core/lib/src/types/exception/analytics/analytics_exception.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import 'package:amplify_core/amplify_core.dart';
4+
part of '../amplify_exception.dart';
55

66
/// Base Class for Analytics Exceptions.
7-
abstract class AnalyticsException extends AmplifyException {
7+
sealed class AnalyticsException extends AmplifyException {
88
const AnalyticsException(
99
super.message, {
1010
super.recoverySuggestion,

packages/amplify_core/lib/src/types/exception/analytics/invalid_event_exception.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import 'package:amplify_core/amplify_core.dart';
4+
part of '../amplify_exception.dart';
55

66
/// {@template amplify_core.analytics.invalid_event_exception}
77
/// Exception when event data is invalid and

packages/amplify_core/lib/src/types/exception/api/api_exception.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import 'package:amplify_core/amplify_core.dart';
4+
part of '../amplify_exception.dart';
55

66
/// {@template amplify_core.api.api_exception}
77
/// Exception thrown from the API Category.
88
/// {@endtemplate}
9-
abstract class ApiException extends AmplifyException {
9+
sealed class ApiException extends AmplifyException {
1010
/// {@macro api_exception}
1111
const ApiException(
1212
super.message, {

packages/amplify_core/lib/src/types/exception/api/http_status_exception.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import 'package:amplify_core/amplify_core.dart';
4+
part of '../amplify_exception.dart';
55

66
@Deprecated('Use HttpStatusException instead')
77
typedef RestException = HttpStatusException;

packages/amplify_core/lib/src/types/exception/api/operation_exception.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import 'package:amplify_core/src/types/exception/api/api_exception.dart';
4+
part of '../amplify_exception.dart';
55

66
/// {@template amplify_core.api.api_operation_error}
77
/// An in-process operation encountered a processing error

packages/amplify_core/lib/src/types/exception/push/push_notification_exception.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import 'package:amplify_core/amplify_core.dart';
4+
part of '../amplify_exception.dart';
55

66
/// {@template amplify_core.push.push_notifications_exception}
77
/// Base Class for Push Notification Exceptions

0 commit comments

Comments
 (0)