PRFFailure class
Enhanced Failure class for comprehensive error handling.
Example usage:
throw PRFFailure(
message: 'Failed to fetch user data',
statusCode: 404,
type: PRFErrorType.notFound,
severity: PRFErrorSeverity.medium,
technicalMessage: 'GET /api/users/123 returned 404',
);
Constructors
-
PRFFailure({required String message, int? statusCode, PRFErrorType type = PRFErrorType.unknown, PRFErrorSeverity severity = PRFErrorSeverity.medium, String? technicalMessage, bool isRecoverable = true, StackTrace? stackTrace, Map<
String, dynamic> context = const {}}) -
const
- PRFFailure.authentication({String message = 'Authentication failed. Please sign in again.', StackTrace? stackTrace})
-
Create a PRFFailure for authentication errors.
factory
-
Create a PRFFailure for authorization errors.
factory
- PRFFailure.fromException(Object error, [StackTrace? stackTrace])
-
Create a PRFFailure from a generic exception.
factory
- PRFFailure.fromStatusCode(int statusCode, String message, [StackTrace? stackTrace])
-
Create a PRFFailure from an HTTP status code.
factory
- PRFFailure.noConnection({StackTrace? stackTrace})
-
Create a PRFFailure for no network connection.
factory
- PRFFailure.timeout({StackTrace? stackTrace})
-
Create a PRFFailure for timeout.
factory
Properties
-
context
→ Map<
String, dynamic> -
Additional context data for debugging.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- isRecoverable → bool
-
Whether the user can recover from this error (e.g., retry).
final
- message → String
-
User-friendly error message suitable for display.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- severity → PRFErrorSeverity
-
Severity level for logging/alerting.
final
- stackTrace → StackTrace?
-
Stack trace for debugging.
final
- statusCode → int?
-
HTTP status code, if applicable.
final
- technicalMessage → String?
-
Technical details for debugging (not shown to users).
final
- type → PRFErrorType
-
Type of error for categorization.
final
Methods
-
copyWith(
{String? message, int? statusCode, PRFErrorType? type, PRFErrorSeverity? severity, String? technicalMessage, bool? isRecoverable, StackTrace? stackTrace, Map< String, dynamic> ? context}) → PRFFailure - Create a copy of this PRFFailure with updated fields.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override