Skip to content

Commit

Permalink
change cakeError() to throw exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
basuke authored and Yosuke Basuke Suzuki committed Sep 7, 2011
1 parent 269cc07 commit 8bec517
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cake/libs/model/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ protected function _generateAssociation($type) {
* Sets a custom table for your controller class. Used by your controller to select a database table.
*
* @param string $tableName Name of the custom table
* @throws MissingTableException when database table $tableName is not found on data source
* @return void
*/
public function setSource($tableName) {
Expand All @@ -968,11 +969,10 @@ public function setSource($tableName) {
if ($db->isInterfaceSupported('listSources')) {
$sources = $db->listSources();
if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) {
return $this->cakeError('missingTable', array(array(
'className' => $this->alias,
throw new MissingTableException(array(
'table' => $this->tablePrefix . $tableName,
'code' => 500
)));
'class' => $this->alias
));
}
$this->_schema = null;
}
Expand Down Expand Up @@ -2983,6 +2983,7 @@ public function getAffectedRows() {
*
* @param string $dataSource The name of the DataSource, as defined in app/Config/database.php
* @return boolean True on success
* @throws MissingConnectionException
*/
public function setDataSource($dataSource = null) {
$oldConfig = $this->useDbConfig;
Expand All @@ -3002,7 +3003,7 @@ public function setDataSource($dataSource = null) {
}

if (empty($db) || !is_object($db)) {
return $this->cakeError('missingConnection', array(array('code' => 500, 'className' => $this->alias)));
throw new MissingConnectionException(array('class' => $this->name));
}
}

Expand Down

0 comments on commit 8bec517

Please sign in to comment.