diff --git a/panel/command/serve.py b/panel/command/serve.py index 1b580da9ca..a2fffcdad6 100644 --- a/panel/command/serve.py +++ b/panel/command/serve.py @@ -570,19 +570,19 @@ def setup_file(): try: with add_sys_path('./'): plugin_module = importlib.import_module(plugin) - except ModuleNotFoundError: + except ModuleNotFoundError as e: raise Exception( f'Specified plugin module {plugin!r} could not be found. ' 'Ensure the module exists and is in the right path. ' - ) + ) from e try: - routes = getattr(plugin_module, 'ROUTES') - except AttributeError: + routes = plugin_module.ROUTES + except AttributeError as e: raise Exception( f'The plugin module {plugin!r} does not declare ' 'a ROUTES variable. Ensure that the module provides ' 'a list of ROUTES to serve.' - ) + ) from e patterns.extend(routes) if args.oauth_provider: