Пример #1
0
	/**
	 * Gets an object of a class with the stored name passed as parameter.
	 *
	 * The method loads a stored object, which has to be stored with storeObject() before.
	 * The parameter is case sensitive. On failure a CoreException will be thrown (error code 1).
	 *
	 * Alternative: You can use the global wrapper function Core to get the stored objects. Just use
	 * Core(DB) for the DB class or Core(My) for an object that as been stored under the name My.
	 * You can either specify a string with the name or the constant as parameter.
	 *
	 * @param	string|int	Stored name of object as string or constant (internally that's an int)
	 * @return	Object		Returns the object
	 * @see Core()
	 * @throws CoreException
	 */
	public static function getObject($objectId) {
		if (is_string($objectId)) {
			$objectId = constant($objectId);
		}
		if (isset(self::$namedObjects[$objectId]) && is_object(self::$namedObjects[$objectId])) {
			return self::$namedObjects[$objectId];
		}
		else {
			$e = new CoreException("Object with name '{$objectId}' not found.", 1);
			$e->setArrayData(self::$namedObjects);
			throw $e;
		}

	}
Пример #2
0
 /**
  * Construct an instance of a LackOfCoffeeException.
  *
  * @param string $message
  * @param int $code
  * @param Exception|null $previous
  */
 public function __construct($message = '', $code = 0, Exception $previous = null)
 {
     if ($message == '') {
         $message = static::DEFAULT_PREFIX . ' Coffee time!';
     } else {
         $message = static::DEFAULT_PREFIX . ' ' . $message;
     }
     parent::__construct($message, $code, $previous);
 }
Пример #3
0
 public function __construct($sIssue, $aContext, $oException = null)
 {
     if ($oException != null) {
         $aContext['mysql_error'] = $oException->getCode();
         $aContext['mysql_errno'] = $oException->getMessage();
     } else {
         $aContext['mysql_error'] = CMDBSource::GetError();
         $aContext['mysql_errno'] = CMDBSource::GetErrNo();
     }
     parent::__construct($sIssue, $aContext);
 }
Пример #4
0
 public function toss()
 {
     $args = func_get_args();
     $message = $args[0];
     if (is_array($message)) {
         self::$_errors = $message;
         $message = implode('', $message);
     }
     unset($args[0]);
     $out = $args ? vsprintf($message, $args) : $message;
     self::$_errors[] = $out;
     throw new \Exception($out);
 }
 public function __construct($sIssue, $sInput, $iLine, $iCol, $sUnexpected, $aExpecting = null)
 {
     $this->m_MyIssue = $sIssue;
     $this->m_sInput = $sInput;
     $this->m_iLine = $iLine;
     $this->m_iCol = $iCol;
     $this->m_sUnexpected = $sUnexpected;
     $this->m_aExpecting = $aExpecting;
     if (is_null($this->m_aExpecting) || count($this->m_aExpecting) == 0) {
         $sMessage = "{$sIssue} - found '{$this->m_sUnexpected}' at {$iCol} in '{$sInput}'";
     } else {
         $sExpectations = '{' . implode(', ', $this->m_aExpecting) . '}';
         $sSuggest = self::FindClosestString($this->m_sUnexpected, $this->m_aExpecting);
         $sMessage = "{$sIssue} - found '{$this->m_sUnexpected}' at {$iCol} in '{$sInput}', expecting {$sExpectations}, I would suggest to use '{$sSuggest}'";
     }
     // make sure everything is assigned properly
     parent::__construct($sMessage, 0);
 }
Пример #6
0
 public function __construct($error)
 {
     parent::__construct($this->formatErrorMessage($error));
 }
Пример #7
0
 public function __construct($message)
 {
     parent::__construct($message);
     $this->code = '01';
 }