PLZ: A handy PHP library for lazy programmers
  • Namespace
  • Class
  • Tree
  • Todo

Namespaces

  • amekusa
    • plz
  • PHP

Classes

  • amekusa\plz\alt
  • amekusa\plz\arr
  • amekusa\plz\constant
  • amekusa\plz\dom
  • amekusa\plz\fn
  • amekusa\plz\num
  • amekusa\plz\obj
  • amekusa\plz\op
  • amekusa\plz\path
  • amekusa\plz\str
  • amekusa\plz\sys
  • amekusa\plz\T
  • amekusa\plz\type
  • amekusa\plz\xml

Exceptions

  • amekusa\plz\ErrorException
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 
<?php namespace amekusa\plz; main::required;

/**
 * A catchable error representation
 * @author amekusa <post@amekusa.com>
 */
class ErrorException extends \ErrorException {

    /**
     * Creates an instance
     * @param string $Msg [optional] The Exception message to throw
     * @param integer $Code [optional] The Exception code
     * @param integer $Severity [optional] The severity level of the exception
     * @param string $File [optional] The filename where the exception is thrown
     * @param integer $Line [optional] The line number where the exception is thrown
     * @param \Exception $Previous [optional] The previous exception used for the exception chaining
     * @return ErrorException An instance
     */
    public static function create($Msg = null, $Code = null, $Severity = null, $File = null, $Line = null, $Previous = null) {
        return new static($Msg, $Code, $Severity, $File, $Line, $Previous);
    }

    /**
     * Triggers a PHP error
     * @param boolean $ShowsStackTrace [optional] Whether to include the stack trace into the error message
     */
    public function trigger($ShowsStackTrace = false) {
        $msg = $this->getMessage();
        if ($ShowsStackTrace) $msg .= "\nStack Trace:\n{$this->getTraceAsString()}";
        $severity = null;
        switch ($this->getSeverity()) {
            case E_NOTICE:
            case E_USER_NOTICE:
                $severity = E_USER_NOTICE;
                break;
            case E_WARNING:
            case E_USER_WARNING:
                $severity = E_USER_WARNING;
                break;
            case E_DEPRECATED:
            case E_USER_DEPRECATED:
                $severity = E_USER_DEPRECATED;
                break;
            default:
                $severity = E_USER_ERROR;
        }
        trigger_error($msg, $severity);
    }

    /**
     * Whether the current error reporting level satisfies this exception's severity
     * @return boolean
     */
    public function shouldReport() {
        return error_reporting() & $this->getSeverity();
    }
}
PLZ: A handy PHP library for lazy programmers API documentation generated by ApiGen