Better error reporting for errors when sending video to dreambox
authorChristian Weiske <cweiske@cweiske.de>
Wed, 6 Mar 2019 20:20:40 +0000 (21:20 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 6 Mar 2019 20:20:40 +0000 (21:20 +0100)
www/functions.php
www/play.php

index ffd6667c685d520d0b9d110e055d54134e40b5ba..b094e36e042c6b417551a0692aa80088957a59f5 100644 (file)
@@ -114,6 +114,13 @@ function playVideoOnDreambox($videoUrl, $dreamboxUrl)
     ini_set('track_errors', 1);
     $xml = @file_get_contents($dreamboxUrl . '/web/session');
     if ($xml === false) {
+        if (!isset($http_response_header)) {
+            errorOut(
+                'Error fetching dreambox web interface token: '
+                . $GLOBALS['lastError']
+            );
+        }
+
         list($http, $code, $message) = explode(
             ' ', $http_response_header[0], 3
         );
@@ -161,4 +168,11 @@ function playVideoOnDreambox($videoUrl, $dreamboxUrl)
         );
     }
 }
+
+function errorHandlerStore($number, $message, $file, $line)
+{
+    $GLOBALS['lastError'] = $message;
+    return false;
+}
+$GLOBALS['lastError'] = null;
 ?>
index 983cd7ff37f166ad2d13b1e61dc5a4f9ff1e6a3d..810995123a9881030249c296421364ec3b657b45 100644 (file)
@@ -8,6 +8,8 @@ if (file_exists($cfgFile)) {
     include $cfgFile;
 }
 
+set_error_handler('errorHandlerStore');
+
 $pageUrl  = getPageUrl();
 $json     = getYoutubeDlJson($pageUrl, $youtubedlPath);
 $videoUrl = extractVideoUrlFromJson($json);