Skip to content

Commit

Permalink
Fix handling exceptions / errors with PHP 7
Browse files Browse the repository at this point in the history
Restrict compatibility with PHP 7.4
This implies major changes, with no BC, require more tests
  • Loading branch information
Loenix committed May 12, 2020
1 parent 64cafad commit ce659b8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -12,6 +12,7 @@
}
},
"require": {
"php": "7.4.*",
"orpheus/orpheus-core": "1.*",
"orpheus/orpheus-entitydescriptor": "1.*",
"orpheus/orpheus-inputcontroller": "1.*",
Expand Down
4 changes: 2 additions & 2 deletions src/Rest/Controller/Api/RestController.php
Expand Up @@ -5,13 +5,13 @@

namespace Orpheus\Rest\Controller\Api;

use Exception;
use Orpheus\EntityDescriptor\User\AbstractUser;
use Orpheus\EntityDescriptor\User\UserApiConnectible;
use Orpheus\Exception\UserException;
use Orpheus\InputController\HTTPController\HTTPController;
use Orpheus\InputController\HTTPController\HTTPRequest;
use Orpheus\InputController\HTTPController\JSONHTTPResponse;
use Throwable;

/**
* Class RestController
Expand Down Expand Up @@ -74,7 +74,7 @@ public function renderOutput($data) {
return new JSONHTTPResponse($data);
}

public function processException(Exception $exception, $values = []) {
public function processException(Throwable $exception, $values = []) {
return JSONHTTPResponse::generateFromException($exception);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Rest/Controller/TemplateController.php
Expand Up @@ -7,7 +7,6 @@

use Orpheus\Config\YAML\YAML;
use Orpheus\Exception\ForbiddenException;
use Orpheus\InputController\HTTPController\JSONHTTPResponse;
use Orpheus\InputController\InputRequest;
use Orpheus\InputController\OutputResponse;
use Orpheus\Rest\Controller\Api\RestController;
Expand All @@ -21,7 +20,7 @@ class TemplateController extends RestController {

/**
* @param InputRequest $request
* @return JSONHTTPResponse|OutputResponse|null
* @return OutputResponse
* @throws ForbiddenException
*/
public function run($request) {
Expand Down
3 changes: 2 additions & 1 deletion src/Rest/XMLHTTPResponse.php
Expand Up @@ -6,6 +6,7 @@
use Orpheus\Exception\UserException;
use Orpheus\Exception\UserReportsException;
use Orpheus\InputController\HTTPController\HTTPResponse;
use Throwable;

/**
* Class XMLHTTPResponse
Expand Down Expand Up @@ -76,7 +77,7 @@ public static function returnData($data) {
* @param string $action
* @return XMLHTTPResponse
*/
public static function generateFromException(Exception $exception, $action = 'Handling the request') {
public static function generateFromException(Throwable $exception, $action = 'Handling the request') {
$code = $exception->getCode();
if( $code < 100 ) {
$code = HTTP_INTERNAL_SERVER_ERROR;
Expand Down

0 comments on commit ce659b8

Please sign in to comment.