1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-12 00:54:11 +02:00

updated for Nette 2.0 beta: exceptions

This commit is contained in:
David Grudl
2011-07-01 07:58:27 +02:00
parent 508e8638e8
commit ac1f45b397
18 changed files with 90 additions and 93 deletions

View File

@@ -689,7 +689,7 @@ class DibiConnection extends DibiObject
$handle = @fopen($file, 'r'); // intentionally @
if (!$handle) {
throw new FileNotFoundException("Cannot open file '$file'.");
throw new RuntimeException("Cannot open file '$file'.");
}
$count = 0;
@@ -726,7 +726,7 @@ class DibiConnection extends DibiObject
*/
public function __wakeup()
{
throw new NotSupportedException('You cannot serialize or unserialize ' . $this->getClass() . ' instances.');
throw new DibiNotSupportedException('You cannot serialize or unserialize ' . $this->getClass() . ' instances.');
}
@@ -736,7 +736,7 @@ class DibiConnection extends DibiObject
*/
public function __sleep()
{
throw new NotSupportedException('You cannot serialize or unserialize ' . $this->getClass() . ' instances.');
throw new DibiNotSupportedException('You cannot serialize or unserialize ' . $this->getClass() . ' instances.');
}
}

View File

@@ -325,7 +325,7 @@ class DibiTableInfo extends DibiObject
*/
protected function initForeignKeys()
{
throw new NotImplementedException;
throw new DibiNotImplementedException;
}
}

View File

@@ -13,14 +13,11 @@
if (!defined('NETTE')) {
class NotImplementedException extends LogicException {}
class NotSupportedException extends LogicException {}
class MemberAccessException extends LogicException {}
class InvalidStateException extends RuntimeException {}
class IOException extends RuntimeException {}
class FileNotFoundException extends IOException {}
}
class DibiNotImplementedException extends LogicException
{}
class DibiNotSupportedException extends LogicException
{}

View File

@@ -87,14 +87,14 @@ abstract class DibiObject
* @param string method name
* @param array arguments
* @return mixed
* @throws \MemberAccessException
* @throws \LogicException
*/
public function __call($name, $args)
{
$class = get_class($this);
if ($name === '') {
throw new MemberAccessException("Call to class '$class' method without name.");
throw new LogicException("Call to class '$class' method without name.");
}
// event functionality
@@ -122,7 +122,7 @@ abstract class DibiObject
return call_user_func_array($cb, $args);
}
throw new MemberAccessException("Call to undefined method $class::$name().");
throw new LogicException("Call to undefined method $class::$name().");
}
@@ -132,12 +132,12 @@ abstract class DibiObject
* @param string method name (in lower case!)
* @param array arguments
* @return mixed
* @throws \MemberAccessException
* @throws \LogicException
*/
public static function __callStatic($name, $args)
{
$class = get_called_class();
throw new MemberAccessException("Call to undefined static method $class::$name().");
throw new LogicException("Call to undefined static method $class::$name().");
}
@@ -208,14 +208,14 @@ abstract class DibiObject
* Returns property value. Do not call directly.
* @param string property name
* @return mixed property value
* @throws \MemberAccessException if the property is not defined.
* @throws \LogicException if the property is not defined.
*/
public function &__get($name)
{
$class = get_class($this);
if ($name === '') {
throw new MemberAccessException("Cannot read a class '$class' property without name.");
throw new LogicException("Cannot read a class '$class' property without name.");
}
// property getter support
@@ -236,7 +236,7 @@ abstract class DibiObject
}
$name = func_get_arg(0);
throw new MemberAccessException("Cannot read an undeclared property $class::\$$name.");
throw new LogicException("Cannot read an undeclared property $class::\$$name.");
}
@@ -246,14 +246,14 @@ abstract class DibiObject
* @param string property name
* @param mixed property value
* @return void
* @throws \MemberAccessException if the property is not defined or is read-only
* @throws \LogicException if the property is not defined or is read-only
*/
public function __set($name, $value)
{
$class = get_class($this);
if ($name === '') {
throw new MemberAccessException("Cannot assign to a class '$class' property without name.");
throw new LogicException("Cannot assign to a class '$class' property without name.");
}
// property setter support
@@ -266,12 +266,12 @@ abstract class DibiObject
} else {
$name = func_get_arg(0);
throw new MemberAccessException("Cannot assign to a read-only property $class::\$$name.");
throw new LogicException("Cannot assign to a read-only property $class::\$$name.");
}
}
$name = func_get_arg(0);
throw new MemberAccessException("Cannot assign to an undeclared property $class::\$$name.");
throw new LogicException("Cannot assign to an undeclared property $class::\$$name.");
}
@@ -293,12 +293,12 @@ abstract class DibiObject
* Access to undeclared property.
* @param string property name
* @return void
* @throws \MemberAccessException
* @throws \LogicException
*/
public function __unset($name)
{
$class = get_class($this);
throw new MemberAccessException("Cannot unset the property $class::\$$name.");
throw new LogicException("Cannot unset the property $class::\$$name.");
}

View File

@@ -107,12 +107,12 @@ class DibiResult extends DibiObject implements IDataSource
/**
* Safe access to property $driver.
* @return IDibiResultDriver
* @throws InvalidStateException
* @throws RuntimeException
*/
private function getDriver()
{
if ($this->driver === NULL) {
throw new InvalidStateException('Result-set was released from memory.');
throw new RuntimeException('Result-set was released from memory.');
}
return $this->driver;