Skip to content

Commit 6e8fcab

Browse files
authored
fix: end buffer if exception occurs in page (#50)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved reliability when loading the Tailscale plugin page by adding robust error handling. * Prevents partial or corrupted page output if an error occurs during content rendering. * Ensures the page cleans up correctly on failures and returns consistent content on success. * No changes to visible functionality; enhances stability and user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Derek Kaser <[email protected]>
1 parent 792ba81 commit 6e8fcab

File tree

1 file changed

+7
-2
lines changed
  • src/usr/local/emhttp/plugins/tailscale/include

1 file changed

+7
-2
lines changed

src/usr/local/emhttp/plugins/tailscale/include/page.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ function includePage(string $filename, array $params = array()): string
4646

4747
if (is_file($filename)) {
4848
ob_start();
49-
include $filename;
50-
return ob_get_clean() ?: "";
49+
try {
50+
include $filename;
51+
return ob_get_clean() ?: "";
52+
} catch (\Throwable $e) {
53+
ob_end_clean();
54+
throw $e;
55+
}
5156
}
5257
return "";
5358
}

0 commit comments

Comments
 (0)