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:
Dag 2022-06-22 18:30:06 +02:00 committed by GitHub
parent 07927008eb
commit fad0dbb6ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 82 deletions

View file

@ -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