Custom error pages must return the correct HTTP status code, explain what went wrong in plain language, and offer the user a way forward without leaking implementation details.
RFC 9110 — HTTP Semantics: 404 Not Found
RFC 9110 — HTTP Semantics: 500 Internal Server Error
Google Search Central — How HTTP status codes affect Google's crawlers