Skip to content

Commit 1340a9f

Browse files
committed
revert die
1 parent 6ff0443 commit 1340a9f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

resources/lib/UnitySite.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77

88
class UnitySite
99
{
10-
public static function die()
10+
public static function die($x = null, $show_user = false)
1111
{
12-
if (CONFIG["site"]["allow_die"]) {
13-
die();
12+
if (CONFIG["site"]["allow_die"] == false) {
13+
if (is_null($x)) {
14+
throw new NoDieException();
15+
} else {
16+
throw new NoDieException($x);
17+
}
1418
} else {
15-
throw new NoDieException();
19+
if (!is_null($x) and $show_user) {
20+
die($x);
21+
} else {
22+
die();
23+
}
1624
}
1725
}
1826

@@ -99,23 +107,23 @@ public static function badRequest($message, $error = null, $data = null)
99107
$errorid = uniqid();
100108
self::errorLog("bad request", $message, $errorid, $error, $data);
101109
self::errorToUser("Invalid requested action or submitted data.", 400, $errorid);
102-
self::die();
110+
self::die($message);
103111
}
104112

105113
public static function forbidden($message, $error = null, $data = null)
106114
{
107115
$errorid = uniqid();
108116
self::errorLog("forbidden", $message, $errorid, $error, $data);
109117
self::errorToUser("Permission denied.", 403, $errorid);
110-
self::die();
118+
self::die($message);
111119
}
112120

113121
public static function internalServerError($message, $error = null, $data = null)
114122
{
115123
$errorid = uniqid();
116124
self::errorLog("internal server error", $message, $errorid, $error, $data);
117125
self::errorToUser("An internal server error has occurred.", 500, $errorid);
118-
self::die();
126+
self::die($message);
119127
}
120128

121129
// https://www.php.net/manual/en/function.register-shutdown-function.php

0 commit comments

Comments
 (0)