Que tal:
function customDie($location) {
header('Location: ' . $location);
exit();
}
mysql_query($sql) or customDie("/error");
function customDie($location) {
header('Location: ' . $location);
exit();
}
mysql_query($sql) or customDie("/error");