ServerResponse.serverError constructor

ServerResponse.serverError({
  1. String message = 'An unexpected error occurred.',
  2. String? html,
})

Creates a 500 Internal Server Error response.

Implementation

factory ServerResponse.serverError({
  String message = 'An unexpected error occurred.',
  String? html,
}) {
  final bodyHtml =
      html ??
      '<!DOCTYPE html><html><head><title>500 Internal Server Error</title></head><body><h1>500 — Server Error</h1><p>$message</p></body></html>';
  return ServerResponse(
    statusCode: 500,
    headers: {
      'Content-Type': 'text/html; charset=utf-8',
      'Cache-Control': 'no-cache, no-store, must-revalidate',
    },
    body: bodyHtml,
  );
}