getMessage()) { case "Duplicate": throw new Exception("A user with this username or email already exists", 400); default: throw $err; } } } public function patch(): void { $code = Input::post("code"); if (empty($code)) throw new Exception("Missing code", 400); try { Response::json(User::confirm($code)); } catch (Exception $err) { switch ($err->getMessage()) { case "NotFound": throw new Exception("User not found", 404); default: throw $err; } } } }