class Entity {
}
class EntityException extends \Exception {
private $entity;
public function getEntity() {
return $this->entity;
}
public static function create($entity, $message = 'Error', $code = 0)
{
$exception = new static($message, $code);
$exception->entity = $entity;
return $exception;
}
}
try {
throw EntityException::create( new Entity, 'Internal error' );
} catch(\EntityException $e) {
// Handle entity exceptions
echo $e->getMessage() . PHP_EOL;
var_dump($e->getEntity());
} catch(\Throwable $e) {
// Handle other exceptions
}
echo "const fileName = '$fileName';";
echo "<a href='javascript:void(0)' onclick='showPdf($fileName)'>{$path_parts['basename']}</a>";
$retry = 8;
$emptyCountLimit = 4;
$emptyCount = 0;
$data = '';
do {
$rcv = stream_socket_recvfrom($stream, $this->bufferSize);
// echo "[+] Read ". strlen($rcv).' bytes. Total: '.strlen($data).PHP_EOL;
if ($rcv === '' || $rcv === false) {
$emptyCount++;
if ($emptyCount >= $emptyCountLimit) break;
continue;
}
$emptyCount = 0;
$data .= $rcv;
} while($retry--);