ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CAS_GracefullTerminationException Class Reference
+ Inheritance diagram for CAS_GracefullTerminationException:
+ Collaboration diagram for CAS_GracefullTerminationException:

Data Structures

class  php
 An exception for terminatinating execution or to throw for unit testing. More...
 

Public Member Functions

 __construct ($message='Terminate Gracefully', $code=0)
 Test if exceptions should be thrown or if we should just exit. More...
 

Static Public Member Functions

static throwInsteadOfExiting ()
 Force phpcas to thow Exceptions instead of calling exit() Needed for unit testing. More...
 

Static Private Attributes

static $_exitWhenThrown = true
 

Detailed Description

Definition at line 43 of file GracefullTerminationException.php.

Constructor & Destructor Documentation

◆ __construct()

CAS_GracefullTerminationException::__construct (   $message = 'Terminate Gracefully',
  $code = 0 
)

Test if exceptions should be thrown or if we should just exit.

In production usage we want to just exit cleanly when prompting the user for a redirect without filling the error logs with uncaught exceptions. In unit testing scenarios we cannot exit or we won't be able to continue with our tests.

Parameters
string$messageMessage Text
string$codeError code
Returns
void

Definition at line 58 of file GracefullTerminationException.php.

References $code, $message, and exit.

59  {
60  // Exit cleanly to avoid filling up the logs with uncaught exceptions.
61  if (self::$_exitWhenThrown) {
62  exit;
63  } else {
64  // Throw exceptions to allow unit testing to continue;
65  parent::__construct($message, $code);
66  }
67  }
$code
Definition: example_050.php:99
catch(Exception $e) $message
exit
Definition: backend.php:16

Member Function Documentation

◆ throwInsteadOfExiting()

static CAS_GracefullTerminationException::throwInsteadOfExiting ( )
static

Force phpcas to thow Exceptions instead of calling exit() Needed for unit testing.

Generally shouldn't be used in production due to an increase in Apache error logging if CAS_GracefulTerminiationExceptions are not caught and handled.

Returns
void

Definition at line 78 of file GracefullTerminationException.php.

79  {
80  self::$_exitWhenThrown = false;
81  }

Field Documentation

◆ $_exitWhenThrown

CAS_GracefullTerminationException::$_exitWhenThrown = true
staticprivate

Definition at line 69 of file GracefullTerminationException.php.


The documentation for this class was generated from the following file: