package components
import (
"context"
"fmt"
)
// ErrorPage renders a generic error page with customizable title, message, and details
templ ErrorPage(ctx context.Context, code int, title, message, details string) {
@LayoutWithContext(fmt.Sprintf("Error %d - %s", code, title), ctx) {
if code == 404 {
} else if code == 401 {
} else if code == 500 {
} else {
}
{ message }
if details != "" {
}
}
}
// NotFoundError renders a 404 Not Found error page
templ NotFoundError(ctx context.Context) {
@ErrorPage(ctx, 404, "Page Not Found", "The page you're looking for doesn't exist or has been moved.", "")
}
// UnauthorizedError renders a 401 Unauthorized error page
templ UnauthorizedError(ctx context.Context) {
@ErrorPage(ctx, 401, "Unauthorized", "You don't have permission to access this page.", "Please log in or contact your administrator if you believe this is a mistake.")
}
// ServerError renders a 500 Internal Server Error page
templ ServerError(ctx context.Context, details string) {
@ErrorPage(ctx, 500, "Server Error", "Something went wrong on our end.", details)
}
// GenericError renders a generic error page
templ GenericError(ctx context.Context, title, message, details string) {
@ErrorPage(ctx, 0, title, message, details)
}