Switch theme by http status code
I've done something similar by implementing the ThemeNegotiatorInterface. In the function that determines which theme should be used, the following code snippet checks for a 404 Page Not Found exception:

$status = \Drupal::requestStack()-&gt;getCurrentRequest()-&gt;attributes-&gt;get('exception');
if ($status &amp;&amp; $status-&gt;getStatusCode() == 404) {
  return 'name_of_the_theme_that_should_handle_404_responses';
}