make errors less ugly

This commit is contained in:
Lee 2023-04-15 19:45:50 +01:00
parent 7b56601353
commit 0932cad5d1

@ -36,7 +36,7 @@ try {
$map = $_FILES["map"]; // the file to upload $map = $_FILES["map"]; // the file to upload
if (!isset($map)) { // if the file is not set if (!isset($map)) { // if the file is not set
echo "No file was uploaded"; header("Location: /?map=No file was uploaded");
die(); die();
} }
@ -45,12 +45,12 @@ try {
$size = $map["size"]; // the size of the file $size = $map["size"]; // the size of the file
if ($size > 100000000) { // if the file is larger than 100MB if ($size > 100000000) { // if the file is larger than 100MB
echo "The file is too large"; header("Location: /?map=File is too large");
die(); die();
} }
if (!isValidBeatSaberMap($file)) { if (!isValidBeatSaberMap($file)) {
echo "The file is not a valid BeatSaber map"; header("Location: /?map=This is not a valid BeatSaber map");
die(); die();
} }
@ -76,12 +76,10 @@ try {
$target_file = $target_dir . $mapId . ".zip"; // the output file path $target_file = $target_dir . $mapId . ".zip"; // the output file path
if (!move_uploaded_file($file, $target_file)) { if (!move_uploaded_file($file, $target_file)) {
error_log("Error: Failed to move uploaded file from $file to $target_file"); error_log("Error: Failed to move uploaded file from $file to $target_file");
echo "There was an error uploading the file"; header("Location: /?map=Failed to upload file");
die(); die();
} }
error_log("Uploaded file moved from $file to $target_file");
header("Location: /?map=https://wip.fascinated.cc/maps/" . $mapId . ".zip"); header("Location: /?map=https://wip.fascinated.cc/maps/" . $mapId . ".zip");
} catch (Exception $e) { } catch (Exception $e) {
echo "There was an error uploading the file. Error: " . $e->getMessage(); echo "There was an error uploading the file. Error: " . $e->getMessage();