Replace echos with proper Exception and trigger_error()
Signed-off-by: Markus Birth <markus@birth-online.de>
This commit is contained in:
@@ -72,9 +72,7 @@ class Mp3FileRemote
|
||||
|
||||
do {
|
||||
// make sure we have this block
|
||||
if (!$this->downloadBlock($blockId)) {
|
||||
throw new Exception('Error downloading block ' . $blockId . ' (starting at pos. ' . ($blockId * $this->blockSize) . ')!');
|
||||
}
|
||||
$this->downloadBlock($blockId);
|
||||
if ($blockPos + $numBytes >= $this->blockSize) {
|
||||
// length of request is more than this block has, truncate to block len
|
||||
$subLen = $this->blockSize - $blockPos;
|
||||
@@ -138,7 +136,7 @@ class Mp3FileRemote
|
||||
*
|
||||
* @param int $blockNo Block to download
|
||||
*
|
||||
* @return bool TRUE if successful
|
||||
* @return bool TRUE if successful, Exception on errors
|
||||
*/
|
||||
protected function downloadBlock(int $blockNo): bool
|
||||
{
|
||||
@@ -166,11 +164,9 @@ class Mp3FileRemote
|
||||
$httpStatus = explode(' ', $status['wrapper_data'][0])[1];
|
||||
if ($httpStatus != '206') {
|
||||
if ($httpStatus != '200') {
|
||||
echo 'Download error!' . PHP_EOL;
|
||||
var_dump($status);
|
||||
return false;
|
||||
throw new Exception('Error downloading block ' . $blockNo . ' (starting at pos. ' . $bytesFrom . ')!\n' . print_r($status, true));
|
||||
}
|
||||
echo 'Server doesn\'t support partial content!' . PHP_EOL;
|
||||
trigger_error('Server doesn\'t support partial content! Downloading whole file.', E_USER_NOTICE);
|
||||
// Content received is whole file from start
|
||||
if ($blockNo != 0) {
|
||||
// move block to start if needed
|
||||
|
Reference in New Issue
Block a user