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 {
|
do {
|
||||||
// make sure we have this block
|
// make sure we have this block
|
||||||
if (!$this->downloadBlock($blockId)) {
|
$this->downloadBlock($blockId);
|
||||||
throw new Exception('Error downloading block ' . $blockId . ' (starting at pos. ' . ($blockId * $this->blockSize) . ')!');
|
|
||||||
}
|
|
||||||
if ($blockPos + $numBytes >= $this->blockSize) {
|
if ($blockPos + $numBytes >= $this->blockSize) {
|
||||||
// length of request is more than this block has, truncate to block len
|
// length of request is more than this block has, truncate to block len
|
||||||
$subLen = $this->blockSize - $blockPos;
|
$subLen = $this->blockSize - $blockPos;
|
||||||
@@ -138,7 +136,7 @@ class Mp3FileRemote
|
|||||||
*
|
*
|
||||||
* @param int $blockNo Block to download
|
* @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
|
protected function downloadBlock(int $blockNo): bool
|
||||||
{
|
{
|
||||||
@@ -166,11 +164,9 @@ class Mp3FileRemote
|
|||||||
$httpStatus = explode(' ', $status['wrapper_data'][0])[1];
|
$httpStatus = explode(' ', $status['wrapper_data'][0])[1];
|
||||||
if ($httpStatus != '206') {
|
if ($httpStatus != '206') {
|
||||||
if ($httpStatus != '200') {
|
if ($httpStatus != '200') {
|
||||||
echo 'Download error!' . PHP_EOL;
|
throw new Exception('Error downloading block ' . $blockNo . ' (starting at pos. ' . $bytesFrom . ')!\n' . print_r($status, true));
|
||||||
var_dump($status);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
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
|
// Content received is whole file from start
|
||||||
if ($blockNo != 0) {
|
if ($blockNo != 0) {
|
||||||
// move block to start if needed
|
// move block to start if needed
|
||||||
|
|||||||
Reference in New Issue
Block a user