Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Nov 20, 2023
1 parent 1e62d2e commit 46aa746
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/php/xp/web/Source.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ private function newInstance($application, $environment) {
$class= $cl->loadClass("xp.{$application}.Web");
}
} catch (ClassLoadingException $e) {
throw new IllegalArgumentException('Cannot load class '.$application, $e);
throw new IllegalArgumentException('Cannot load web application '.$application, $e);
}

if (!$class->isSubclassOf(Application::class)) {
throw new IllegalArgumentException($class->getName().' is not a web.Application');
throw new IllegalArgumentException($class->getName().' is not a web application');
}

return $class->newInstance($environment);
Expand Down
4 changes: 2 additions & 2 deletions src/test/php/web/unittest/SourceTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public function application_class_and_filter() {
Assert::instance(HelloWorld::class, $src->application());
}

#[Test, Expect(class: IllegalArgumentException::class, message: 'Cannot load class not.a.class')]
#[Test, Expect(class: IllegalArgumentException::class, message: 'Cannot load web application not.a.class')]
public function non_existant_class() {
(new Source('not.a.class', $this->environment))->application();
}

#[Test, Expect(class: IllegalArgumentException::class, message: 'util.Date is not a web.Application')]
#[Test, Expect(class: IllegalArgumentException::class, message: 'util.Date is not a web application')]
public function unrelated_class() {
(new Source('util.Date', $this->environment))->application();
}
Expand Down

0 comments on commit 46aa746

Please sign in to comment.