class RealisticDummyContentException in Realistic Dummy Content 8.2
Same name and namespace in other branches
- 7.2 api/src/includes/RealisticDummyContentException.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentException
- 3.x api/src/includes/RealisticDummyContentException.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentException
An Exception.
Hierarchy
- class \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentException extends \Drupal\realistic_dummy_content_api\includes\Exception
Expanded class hierarchy of RealisticDummyContentException
File
- api/
src/ includes/ RealisticDummyContentException.php, line 16
Namespace
Drupal\realistic_dummy_content_api\includesView source
class RealisticDummyContentException extends \Exception {
/**
* Constructor.
*/
public function __construct($message) {
parent::__construct($message);
$this
->log();
}
/**
* Logs a message.
*/
public function log() {
Framework::instance()
->debug($this
->getMessage() . ' (' . $this
->getCaller() . ' called ' . $this
->getCalled() . ')');
}
/**
* Returns the calling function through a backtrace.
*/
public static function getCaller() {
// A funciton x has called a function y which called this
// see stackoverflow.com/questions/190421.
$caller = debug_backtrace();
$caller = $caller[REALISTIC_DUMMY_CONTENT_API_EXCEPTION_BACKTRACE_LEVEL];
$r = $caller['function'] . '()';
if (isset($caller['class'])) {
$r .= ' in ' . $caller['class'];
}
if (isset($caller['object'])) {
$r .= ' (' . get_class($caller['object']) . ')';
}
return $r;
}
/**
* Returns the called function through a backtrace.
*/
public static function getCalled() {
// Get caller will return the called function because the simple fact
// of using another function will make the backtrace one-level deeper.
return self::getCaller();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RealisticDummyContentException:: |
public static | function | Returns the called function through a backtrace. | |
RealisticDummyContentException:: |
public static | function | Returns the calling function through a backtrace. | |
RealisticDummyContentException:: |
public | function | Logs a message. | |
RealisticDummyContentException:: |
public | function | Constructor. |