From 4fb363a3aee766def56e8e55901bd3fc3e9374f9 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 29 Jul 2017 01:07:19 +0200 Subject: [PATCH] [index] Use functions to build exception messages --- index.php | 62 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 60 deletions(-) diff --git a/index.php b/index.php index 2fe37fdf..7fc2f8ad 100644 --- a/index.php +++ b/index.php @@ -166,38 +166,9 @@ try { $bridge->setCache($cache); $bridge->setDatas($params); } catch(Exception $e){ - $title = $bridge->getName() . ' failed with error ' . $e->getCode(); - - // Build a GitHub compatible message - $body = 'Error message: `' - . $e->getmessage() - . "`\nQuery string: `" - . $_SERVER['QUERY_STRING'] . '`'; - - $link = buildGitHubIssueQuery($title, $body, 'bug report', $bridge->getMaintainer()); - - $message = << - - - {$e->getCode()} - {$e->getMessage()} - - -

Error {$e->getCode()} - {$e->getMessage()}

-

{$bridge->getName()} was unable to receive or process the remote website's content! -
Check your input parameters or press F5 to retry. -
If the error persists use this link to notify the bridge maintainer. -
Notice: After clicking on the link you can review the issue before sending it.

-

Additional info

-

Error code: "{$e->getCode()}"

-

Message: "{$e->getMessage()}"

- - -EOD; - header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode())); header('Content-Type: text/html'); - die($message); + die(buildBridgeException($e, $bridge)); } // Data transformation @@ -207,38 +178,9 @@ EOD; $format->setExtraInfos($bridge->getExtraInfos()); $format->display(); } catch(Exception $e){ - $title = $bridge->getName() . ' failed with error ' . $e->getCode(); - - // Build a GitHub compatible message - $body = 'Error message: `' - . $e->getmessage() - . "`\nQuery string: `" - . $_SERVER['QUERY_STRING'] . '`'; - - $link = buildGitHubIssueQuery($title, $body, 'bug report', $bridge->getMaintainer()); - - $message = << - - - {$e->getCode()} - {$e->getMessage()} - - -

Error {$e->getCode()} - {$e->getMessage()}

-

RSS-Bridge was unable to transform the contents returned by {$bridge->getName()}! -
Check your input parameters or press F5 to retry. -
If the error persists use this link to notify the bridge maintainer. -
Notice: After clicking on the link you can review the issue before sending it.

-

Additional info

-

Error code: "{$e->getCode()}"

-

Message: "{$e->getMessage()}"

- - -EOD; - header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode())); header('Content-Type: text/html'); - die($message); + die(buildTransformException($e, $bridge)); } die;