diff --git a/core/templates/exception.php b/core/templates/exception.php
index d26e9ff4f94ed..324724e67ace2 100644
--- a/core/templates/exception.php
+++ b/core/templates/exception.php
@@ -4,20 +4,7 @@
style('core', ['styles', 'header']);
-function print_exception(Throwable $e, \OCP\IL10N $l): void {
- print_unescaped('
');
- p($e->getTraceAsString());
- print_unescaped('
');
-
- if ($e->getPrevious() !== null) {
- print_unescaped('
');
- print_unescaped('');
- p($l->t('Previous'));
- print_unescaped('
');
-
- print_exception($e->getPrevious(), $l);
- }
-}
+require_once __DIR__ . '/print_exception.php';
?>
diff --git a/core/templates/print_exception.php b/core/templates/print_exception.php
new file mode 100644
index 0000000000000..2def6d4e9d904
--- /dev/null
+++ b/core/templates/print_exception.php
@@ -0,0 +1,21 @@
+');
+ p($e->getTraceAsString());
+ print_unescaped('');
+
+ if ($e->getPrevious() !== null) {
+ print_unescaped('
');
+ print_unescaped('
');
+ p($l->t('Previous'));
+ print_unescaped('
');
+
+ print_exception($e->getPrevious(), $l);
+ }
+}
diff --git a/core/templates/print_xml_exception.php b/core/templates/print_xml_exception.php
new file mode 100644
index 0000000000000..94452d8ae9d3f
--- /dev/null
+++ b/core/templates/print_xml_exception.php
@@ -0,0 +1,16 @@
+getTraceAsString());
+
+ if ($e->getPrevious() !== null) {
+ print_unescaped('');
+ print_exception($e->getPrevious(), $l);
+ print_unescaped('');
+ }
+}
diff --git a/core/templates/xml_exception.php b/core/templates/xml_exception.php
index 342238d824bb7..ba808c88595c2 100644
--- a/core/templates/xml_exception.php
+++ b/core/templates/xml_exception.php
@@ -5,15 +5,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
-function print_exception(Throwable $e, \OCP\IL10N $l): void {
- p($e->getTraceAsString());
-
- if ($e->getPrevious() !== null) {
- print_unescaped('');
- print_exception($e->getPrevious(), $l);
- print_unescaped('');
- }
-}
+require_once __DIR__ . '/print_xml_exception.php';
print_unescaped('' . "\n");
?>