mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-14 16:04:42 +02:00
refactor: fix exception handling (#2835)
* refactor: fix exception handling The removed catch is never uses in php versions above 7. The need for multiple catch statements like this is to support both php 5 and 7. * remove traces of old exception handling * add typehints * dont treat exception code 0 specially
This commit is contained in:
parent
07927008eb
commit
fad0dbb6ef
2 changed files with 12 additions and 82 deletions
|
@ -66,20 +66,8 @@ function buildGitHubIssueQuery($title, $body, $labels = null, $maintainer = null
|
|||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception message as HTML string
|
||||
*
|
||||
* @param object $e Exception The exception to show
|
||||
* @param object $bridge object The bridge object
|
||||
* @return string|null Returns the exception as HTML string or null.
|
||||
*
|
||||
* @todo This function belongs inside a class
|
||||
*/
|
||||
function buildBridgeException($e, $bridge){
|
||||
if(( !($e instanceof \Exception) && !($e instanceof \Error)) || !($bridge instanceof \BridgeInterface)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function buildBridgeException(\Throwable $e, BridgeInterface $bridge): string
|
||||
{
|
||||
$title = $bridge->getName() . ' failed with error ' . $e->getCode();
|
||||
|
||||
// Build a GitHub compatible message
|
||||
|
@ -106,20 +94,8 @@ EOD;
|
|||
return $section;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception message as HTML string
|
||||
*
|
||||
* @param object $e Exception The exception to show
|
||||
* @param object $bridge object The bridge object
|
||||
* @return string|null Returns the exception as HTML string or null.
|
||||
*
|
||||
* @todo This function belongs inside a class
|
||||
*/
|
||||
function buildTransformException($e, $bridge){
|
||||
if(( !($e instanceof \Exception) && !($e instanceof \Error)) || !($bridge instanceof \BridgeInterface)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function buildTransformException(\Throwable $e, BridgeInterface $bridge): string
|
||||
{
|
||||
$title = $bridge->getName() . ' failed with error ' . $e->getCode();
|
||||
|
||||
// Build a GitHub compatible message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue