Commit 118f67bb authored by Marc Egger's avatar Marc Egger
Browse files

catch Errors as well as exceptions

parent 86a16097
Pipeline #4079 passed with stages
in 3 minutes and 52 seconds
......@@ -7,8 +7,6 @@ namespace IMATHUZH\Qfq\Controller;
require_once(__DIR__ . '/../../vendor/autoload.php');
use http\Exception;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\QuickFormQuery;
......@@ -67,8 +65,16 @@ class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
} catch (\DownloadException $e) {
$html = $e->formatMessage();
} catch (Exception $e) {
$html = "Generic Exception: " . $e->getMessage();
} catch (\Exception $e) {
$ee = new \UserReportException(json_encode([
ERROR_MESSAGE_TO_USER => "Generic Exception: " . $e->getMessage(),
ERROR_MESSAGE_TO_DEVELOPER => $e->getTraceAsString()]), E_ERROR);
$html = $ee->formatMessage();
} catch (\Error $e) {
$ee = new \UserReportException(json_encode([
ERROR_MESSAGE_TO_USER => "Generic Error: " . $e->getMessage(),
ERROR_MESSAGE_TO_DEVELOPER => $e->getTraceAsString()]), E_ERROR);
$html = $ee->formatMessage();
}
if (isset($e) && $e->getCode() == ERROR_QUIT_QFQ_REGULAR) {
......
......@@ -15,7 +15,7 @@ class Thrower
public static function userFormException(string $errorToUser, string $errorToDeveloper = '', int $errorCode = E_ERROR) {
throw new \UserFormException(json_encode([
ERROR_MESSAGE_TO_USER => $errorToUser,
ERROR_MESSAGE_TO_DEVELOPER => $errorToDeveloper]), ERROR_IO_READ_FILE);
ERROR_MESSAGE_TO_DEVELOPER => $errorToDeveloper]), $errorCode);
}
/**
......@@ -29,6 +29,6 @@ class Thrower
public static function userReportException(string $errorToUser, string $errorToDeveloper = '', int $errorCode = E_ERROR) {
throw new \UserReportException(json_encode([
ERROR_MESSAGE_TO_USER => $errorToUser,
ERROR_MESSAGE_TO_DEVELOPER => $errorToDeveloper]), ERROR_IO_READ_FILE);
ERROR_MESSAGE_TO_DEVELOPER => $errorToDeveloper]), $errorCode);
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment