Do 404s get access to variables set with setRouteVariables?
The simple answer is: no, error handling templates don’t have access to the variables that would be available to the template when the request resolves normally. And we won’t be making it possible.

Technically you could get access to them by creating a plugin that has a template hook which is capable of adding those variables:

craft()-&gt;templates-&gt;hook('mergeRouteVariables', function(&amp;$context)
{
    $routeParams = craft()-&gt;urlManager-&gt;getRouteParams();

    if (isset($routeParams['variables']))
    {
        $context = array_merge($context, $routeParams['variables']);
    }
}


404.html:

{% hook "mergeRouteVariables" %}
{# ... #}



  It's probably worth noting that the reason I'm trying to do this is because I want to include a form on the 404 page (that I also include in other areas, so it's setup as a partial) and I'm having trouble passing error validation back and forth with setRouteVariables, but only for 404 pages. I know I could do this with a session and that is my current work around, but I wanted to see if there was a better way.


While I understand your use case, it's pretty weird that you would have a form that intentionally submits to a 404 page (even though it’s the same page).

Here are a couple alternatives you might want to consider:


You could create a dedicated page for the form, and have the form submit to that page’s URL in the event that it’s coming from a 404.
You could handle the form submission and validation with Javascript/Ajax.