function ErrorTestController::triggerException

Same name in other branches
  1. 9 core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php \Drupal\error_test\Controller\ErrorTestController::triggerException()
  2. 8.9.x core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php \Drupal\error_test\Controller\ErrorTestController::triggerException()
  3. 11.x core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php \Drupal\error_test\Controller\ErrorTestController::triggerException()

Trigger an exception to test the exception handler.

Parameters

string $argument: A function argument which will be included in the exception backtrace.

Throws

\Exception

1 string reference to 'ErrorTestController::triggerException'
error_test.routing.yml in core/modules/system/tests/modules/error_test/error_test.routing.yml
core/modules/system/tests/modules/error_test/error_test.routing.yml

File

core/modules/system/tests/modules/error_test/src/Controller/ErrorTestController.php, line 77

Class

ErrorTestController
Controller routines for error_test routes.

Namespace

Drupal\error_test\Controller

Code

public function triggerException(string $argument = "<script>alert('xss')</script>") : void {
    define('SIMPLETEST_COLLECT_ERRORS', FALSE);
    // Add function arguments to the exception backtrace.
    ini_set('zend.exception_ignore_args', FALSE);
    ini_set('zend.exception_string_param_max_len', 1024);
    throw new \Exception("Drupal & awesome");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.