pub(crate) fn error_page(
        mut self,
        error_page_data: &ServerErrorData,
        error_html: &str,
        error_head: &str,
        locale: Option<String>, // For internal convenience
    ) -> Self {
        // If we have a locale, we'll use the localized JS constants
        if let Some(locale) = locale {
            let consts_import = format!(
                "<script src=\".perseus/initial_consts/{}.js\"></script>",
                &locale
            );
            self.head_after_boundary.push(consts_import);
            self.locale = locale;
        } else {
            self.head_after_boundary
                .push("<script src=\".perseus/initial_consts.js\"></script>".to_string());
        }

        let error = serde_json::to_string(error_page_data).unwrap();
        let state_var = format!(
            "window.__PERSEUS_INITIAL_STATE = `error-{}`;",
            escape_page_data(&error),
        );
        self.scripts_after_boundary.push(state_var);

        self.head_after_boundary.push(error_head.to_string());
        self.content = error_html.into();

        self
    }
Interpolates page error data into the shell in the event of a failure.

This takes an optional translations string if it's available, injecting
it if possible. If the reactor finds this variable to be empty on an
error extracted from the initial state variable, it will assume the
error is unlocalized.
packages/perseus/src/server/html_shell.rs