diff --git a/src/Event/Event.php b/src/Event/Event.php index 99029333..852346e1 100644 --- a/src/Event/Event.php +++ b/src/Event/Event.php @@ -4,9 +4,6 @@ namespace Bow\Event; -use Bow\Session\Session; -use Bow\Container\Action; -use Bow\Support\Collection; use Bow\Event\Contracts\AppEvent; class Event diff --git a/src/Http/Request.php b/src/Http/Request.php index 7e8dd774..c148ef4f 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -5,6 +5,7 @@ namespace Bow\Http; use Bow\Auth\Authentication; +use Bow\Http\Exception\BadRequestException; use Bow\Session\Session; use Bow\Support\Collection; use Bow\Support\Str; @@ -52,7 +53,11 @@ private function __construct() $this->id = "req_" . sha1(uniqid() . time()); if ($this->getHeader('content-type') == 'application/json') { - $data = json_decode(file_get_contents("php://input"), true, 1024, JSON_THROW_ON_ERROR); + try { + $data = json_decode(file_get_contents("php://input"), true, 1024, JSON_THROW_ON_ERROR); + } catch (\Throwable $e) { + throw new BadRequestException("Invalid JSON syntax"); + } $this->input = array_merge((array) $data, $_GET); } else { $data = $_POST ?? [];