Skip to content

Commit

Permalink
Reorganizing Exceptions Namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
rotimi committed Feb 4, 2024
1 parent 5431159 commit af5ff6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/LeanOrm/Exceptions/BadModelPrimaryColumnNameException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
declare(strict_types=1);
namespace LeanOrm\Exceptions;

class BadModelPrimaryColumnNameException extends \Exception{}
4 changes: 2 additions & 2 deletions src/LeanOrm/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function __construct(
$msg = "ERROR: The Primary Key column name `{$primary_col_name}` supplied to "
. static::class . '::' . __FUNCTION__ . '(...)'
. " does not exist as an actual column in the supplied table `{$this->getTableName()}`.";
throw new BadModelPrimaryColumnNameException($msg);
throw new \LeanOrm\Exceptions\BadModelPrimaryColumnNameException($msg);
}

/** @psalm-suppress MixedAssignment */
Expand Down Expand Up @@ -1279,7 +1279,7 @@ protected function createRelatedModelObject(
. PHP_EOL;
throw new RelatedModelNotCreatedException($msg);

} catch(BadModelPrimaryColumnNameException) {
} catch(\LeanOrm\Exceptions\BadModelPrimaryColumnNameException) {

$msg = "ERROR: Couldn't create foreign model of type '{$f_models_class_name}'."
. " The supplied primary key column `{$pri_key_col_in_f_models_table}` "
Expand Down
2 changes: 1 addition & 1 deletion tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testThatConstructorWithNonExistentTableNameWorksAsExpected() {

public function testThatConstructorWithNonExistentPrimaryColumnNameWorksAsExpected() {

$this->expectException(\LeanOrm\BadModelPrimaryColumnNameException::class);
$this->expectException(\LeanOrm\Exceptions\BadModelPrimaryColumnNameException::class);

$model = new $this->modelClass(static::$dsn, static::$username ?? "", static::$password ?? "",[],'non_existent_column','authors');
}
Expand Down

0 comments on commit af5ff6d

Please sign in to comment.