Hopefully a future Flarum version will be able to use the single page application for error pages, as it would allow opening the login modal on the page itself and allow for page reload without losing the target URL.
As things stand, the error page must be a basic HTML page, but it can be modified to include some explanation and links. You could use this extension to modify the 404 page to better suit your community https://discuss.flarum.org/d/10784-friendsofflarum-custom-html-error-pages