[index] Change error messages to HTML

This commit is contained in:
logmanoriginal 2017-07-28 23:24:29 +02:00
parent 27fad6d2af
commit 97cd3e6169

View File

@ -167,7 +167,14 @@ try {
$bridge->setDatas($params); $bridge->setDatas($params);
} catch(Exception $e){ } catch(Exception $e){
$title = urlencode($bridge->getName() . ' failed with error ' . $e->getCode()); $title = urlencode($bridge->getName() . ' failed with error ' . $e->getCode());
$body = urlencode('Error message: ' . $e->getmessage());
// Build a GitHub compatible message
$body = urlencode('Error message: `'
. $e->getmessage()
. "`\nQuery string: `"
. $_SERVER['QUERY_STRING'] . '`'
);
$link = 'https://github.com/rss-bridge/rss-bridge/issues/new?title=' $link = 'https://github.com/rss-bridge/rss-bridge/issues/new?title='
. $title . $title
. '&body=' . '&body='
@ -177,20 +184,25 @@ try {
. $bridge->getMaintainer(); . $bridge->getMaintainer();
$message = <<<EOD $message = <<<EOD
{$bridge->getName()} was unable to receive or process the remote website's content. <!DOCTYPE html>
Check your input parameters or press F5 to retry. <html lang="en">
<head>
Use the following link to notify the bridge maintainer if this error persists: <title>{$e->getCode()} - {$e->getMessage()}</title>
$link </head>
<body>
Additional info: <h1>Error {$e->getCode()} - {$e->getMessage()}</h1>
<p><strong>{$bridge->getName()}</strong> was unable to receive or process the remote website's content!
Error code: "{$e->getCode()}" <br>Check your input parameters or press F5 to retry.
Message: "{$e->getMessage()}" <br>Use <a href="{$link}">this</a> link to notify the bridge maintainer if this error persists.</p>
<h2>Additional info</h2>
<p>Error code: "{$e->getCode()}"</p>
<p>Message: "{$e->getMessage()}"</p>
</body>
</html>
EOD; EOD;
header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode())); header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode()));
header('Content-Type: text/plain'); header('Content-Type: text/html');
die($message); die($message);
} }
@ -202,7 +214,14 @@ EOD;
$format->display(); $format->display();
} catch(Exception $e){ } catch(Exception $e){
$title = urlencode($bridge->getName() . ' failed with error ' . $e->getCode()); $title = urlencode($bridge->getName() . ' failed with error ' . $e->getCode());
$body = urlencode('Error message: ' . $e->getmessage());
// Build a GitHub compatible message
$body = urlencode('Error message: `'
. $e->getmessage()
. "`\nQuery string: `"
. $_SERVER['QUERY_STRING'] . '`'
);
$link = 'https://github.com/rss-bridge/rss-bridge/issues/new?title=' $link = 'https://github.com/rss-bridge/rss-bridge/issues/new?title='
. $title . $title
. '&body=' . '&body='
@ -212,20 +231,25 @@ EOD;
. $bridge->getMaintainer(); . $bridge->getMaintainer();
$message = <<<EOD $message = <<<EOD
RSS-Bridge was unable to transform the contents returned by {$bridge->getName()}! <!DOCTYPE html>
Check your input parameters or press F5 to retry. <html lang="en">
<head>
Use the following link to notify the bridge maintainer if this error persists: <title>{$e->getCode()} - {$e->getMessage()}</title>
$link </head>
<body>
Additional info: <h1>Error {$e->getCode()} - {$e->getMessage()}</h1>
<p>RSS-Bridge was unable to transform the contents returned by <strong>{$bridge->getName()}</strong>!
Error code: "{$e->getCode()}" <br>Check your input parameters or press F5 to retry.
Message: "{$e->getMessage()}" <br>Use <a href="{$link}">this</a> link to notify the bridge maintainer if this error persists.</p>
<h2>Additional info</h2>
<p>Error code: "{$e->getCode()}"</p>
<p>Message: "{$e->getMessage()}"</p>
</body>
</html>
EOD; EOD;
header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode())); header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode()));
header('Content-Type: text/plain'); header('Content-Type: text/html');
die($message); die($message);
} }