diff --git a/src/think/route/dispatch/Callback.php b/src/think/route/dispatch/Callback.php index c0f9a160b1..35815c17fe 100644 --- a/src/think/route/dispatch/Callback.php +++ b/src/think/route/dispatch/Callback.php @@ -12,6 +12,7 @@ namespace think\route\dispatch; +use think\exception\ClassNotFoundException; use think\route\Dispatch; /** @@ -49,7 +50,12 @@ public function exec() ->setController($controller) ->setAction($action); - $instance = $this->app->invokeClass($class); + if (class_exists($class)) { + $instance = $this->app->invokeClass($class); + } else { + throw new ClassNotFoundException('class not exists:' . $class, $class); + } + return $this->responseWithMiddlewarePipeline($instance, $action); }