Refine error handling in ui/alternate.php