Error Page httpResponseHead.statusCode overridden to 404

We have an error page in which we replace the 404 page with a 410 when the page has a hiddenAfterDateTime less than two weeks in the past.

In the error page we set the status code to 410 correctly using the httpResponseHead.statusCode = ${statusCode}

As far as I can see this is reset in the Neos\Flow\Error\DebugExceptionHandler->echoExceptionWeb lines 64-68

Currently in the normal fusion views the status codes set in the httpResponseHead are respected, where would I need to look in order to port this functionality over to the error case?