defaultErrorPage function
The default error page: a small HTML page with the status and its
title, like 404 Not Found. With debug, it also shows the error
text and the stack trace. It loads no files from outside.
Implementation
String defaultErrorPage(
int status,
Object error,
StackTrace stackTrace,
bool debug,
) {
String title = _escape.convert('$status ${_title(status)}');
String details = '';
if (debug) {
Object? message = error is IHttpException ? error.message : error;
details =
'<p>${_escape.convert('$message')}</p>'
'<pre>${_escape.convert('$stackTrace')}</pre>';
}
return '<!doctype html><html lang="en"><head><meta charset="utf-8">'
'<meta name="viewport" content="width=device-width, initial-scale=1">'
'<title>$title</title><style>'
'body{margin:0;padding:48px 16px;font-family:system-ui,sans-serif;'
'color:#222;background:#fafafa}main{max-width:760px;margin:0 auto}'
'h1{font-size:28px;font-weight:600}pre{white-space:pre-wrap;'
'overflow:auto;font-size:13px;padding:12px;background:#fff;'
'border:1px solid #ddd}</style></head>'
'<body><main><h1>$title</h1>$details</main></body></html>';
}