Is there something like a wildcard directive to catch all possible errors and deal with them in a single custom error page?
ErrorDocument 404 /error.php?code
That is not possible. You need to have a ErrorDocument directive for each status code you want to handle differently than with the default error handler.
ErrorDocument