PageError class final
Response for rendering an error page.
Use this to display error pages with appropriate HTTP status codes.
Usage
// Generic server error (500)
return PageError('Something went wrong');
// Not found (404)
return PageError.notFound('User not found');
// Bad request (400)
return PageError.badRequest('Invalid ID format');
// Forbidden (403)
return PageError.forbidden('Access denied');
// With additional data for the error page
return PageError(
'Validation failed',
statusCode: 422,
data: {'errors': validationErrors},
);
- Inheritance
-
- Object
- PageResponse<
Never> - PageError
Constructors
-
PageError(String message, {int statusCode = 500, Map<
String, dynamic> data = const {}, List<Cookie> cookies = const []}) -
Creates an error response with the given
message.const -
PageError.badRequest([String message = 'Bad request', List<
Cookie> cookies = const []]) -
Creates a 400 Bad Request error.
const
-
PageError.forbidden([String message = 'Access denied', List<
Cookie> cookies = const []]) -
Creates a 403 Forbidden error.
const
-
PageError.notFound([String message = 'Page not found', List<
Cookie> cookies = const []]) -
Creates a 404 Not Found error.
const
-
Creates a 401 Unauthorized error.
const
Properties
-
Creates an error response with the given message.
final
-
data
→ Map<
String, dynamic> -
Additional data for the error page template.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- message → String
-
The error message to display.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statusCode → int
-
HTTP status code for the error.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited