If a user now clicks on the link, and ultimately ends up on a typical 404 page, then this is unsatisfactory for everyone involved.
- The user does not get the result he expected
- Google could not provide the user with a relevant result
- For the site operator, it is also not desirable the visitor did not find what was wanted
Of course, the ranking of your page is not immediately devalued just because here and there once an error page has crept.
But important is that you react here in any case, and proactively look into the Search Console to determine if, where, and how many errors have crept in.
If such error pages accumulate over time and over a longer period of time, your page will certainly be devalued in the relevance of search queries. You may also want to proactively submit an updated Sitemap through Google Search Console.