diff --git a/class.databaserecord.php b/class.databaserecord.php index 908216f..3bfa521 100644 --- a/class.databaserecord.php +++ b/class.databaserecord.php @@ -60,7 +60,7 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass else { $classname = get_class($this); - throw new NotFoundException("Could not locate {$classname} {$uDataSource} in database."); + throw new NotFoundException("Could not locate {$classname} {$uDataSource} in database.", 0, null, ""); } } else @@ -179,7 +179,15 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass { if($type == $class_type) { - $value = new $class_name($original_value); + try + { + $value = new $class_name($original_value); + } + catch (NotFoundException $e) + { + $e->field = $variable_name; + throw $e; + } $variable_type = CPHP_VARIABLE_SAFE; $found = true; } diff --git a/include.exceptions.php b/include.exceptions.php index 1acecfd..12e4641 100644 --- a/include.exceptions.php +++ b/include.exceptions.php @@ -15,7 +15,6 @@ if($_CPHP !== true) { die(); } class OwnershipException extends Exception {} class UserAccessException extends Exception {} -class NotFoundException extends Exception {} class PrototypeException extends Exception {} class ConstructorException extends Exception {} class MissingDataException extends Exception {} @@ -39,5 +38,15 @@ class TemplateException extends Exception } } +class NotFoundException extends Exception +{ + public function __construct($message, $code = 0, $previous = null, $field = "") + { + $this->field = $field; + + parent::__construct($message, $code, $previous); + } +} + class TemplateSyntaxException extends TemplateException {} class TemplateParsingException extends TemplateException {}