Default-namespace changes.

- Added new ClassNotFoundHttpException thrown when class is not found.
- ClassNotFoundHttpException is now thrown when class/method is not found (backwards compatible).
- Added unit-tests for default-namespace tests (rewrite + append cases).
This commit is contained in:
Simon Sessingø
2021-03-22 17:03:22 +01:00
parent fd585e8b9d
commit fa83d2f74b
4 changed files with 79 additions and 11 deletions
@@ -3,6 +3,7 @@
namespace Pecee\SimpleRouter\ClassLoader;
use DI\Container;
use Pecee\SimpleRouter\Exceptions\ClassNotFoundHttpException;
use Pecee\SimpleRouter\Exceptions\NotFoundHttpException;
class ClassLoader implements IClassLoader
@@ -28,7 +29,7 @@ class ClassLoader implements IClassLoader
public function loadClass(string $class)
{
if (class_exists($class) === false) {
throw new NotFoundHttpException(sprintf('Class "%s" does not exist', $class), 404);
throw new ClassNotFoundHttpException(sprintf('Class "%s" does not exist', $class), 404, null, $class);
}
if ($this->useDependencyInjection === true) {