Skip to content

Commit 64d366d

Browse files
docs(exceptions): enhance PolicySDKException documentation
1 parent cbc5472 commit 64d366d

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

lib/src/exceptions/policy_sdk_exception.dart

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,63 @@
11
import 'package:flutter_policy_engine/src/exceptions/i_policy_sdk_exceptions.dart';
22

3+
/// A concrete implementation of [IPolicySDKException] that represents
4+
/// errors occurring within the Flutter Policy Engine SDK.
5+
///
6+
/// This exception class provides detailed error information including
7+
/// a descriptive message and an optional underlying exception that
8+
/// caused the error. It's used throughout the SDK to provide consistent
9+
/// error handling and reporting.
10+
///
11+
/// Example usage:
12+
/// ```dart
13+
/// try {
14+
/// // SDK operation that might fail
15+
/// } catch (e) {
16+
/// throw PolicySDKException(
17+
/// 'Failed to load policy configuration',
18+
/// exception: e,
19+
/// );
20+
/// }
21+
/// ```
322
class PolicySDKException implements IPolicySDKException {
23+
/// Creates a new [PolicySDKException] with the specified error message
24+
/// and optional underlying exception.
25+
///
26+
/// The [message] should provide a clear, human-readable description
27+
/// of what went wrong. The [exception] parameter can be used to
28+
/// preserve the original exception that caused this error, which
29+
/// is useful for debugging and error tracing.
30+
///
31+
/// Parameters:
32+
/// - [message]: A descriptive error message explaining what went wrong
33+
/// - [exception]: An optional underlying exception that caused this error
434
PolicySDKException(
535
this.message, {
636
required this.exception,
737
});
838

39+
/// A descriptive message explaining the error that occurred.
40+
///
41+
/// This message should be clear enough for developers to understand
42+
/// what went wrong and potentially how to fix it.
943
@override
1044
final String message;
1145

46+
/// The underlying exception that caused this SDK error, if any.
47+
///
48+
/// This field preserves the original exception for debugging purposes.
49+
/// It can be null if the error was generated directly by the SDK
50+
/// without an underlying exception.
1251
final Exception? exception;
1352

53+
/// Returns a string representation of this exception.
54+
///
55+
/// The returned string includes the SDK exception message and,
56+
/// if available, the underlying exception information for debugging.
57+
///
58+
/// Returns:
59+
/// A formatted string containing the error message and optional
60+
/// underlying exception details.
1461
@override
1562
String toString() {
1663
final buffer = StringBuffer('SDKException: $message');

0 commit comments

Comments
 (0)