We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
__main__ top-level script shadowing ImportError
Given `main.py`:
```python
import nonexistent  # assuming this is... non-existent
from sanic import Sanic, response


app = Sanic(__name__)


@app.route('/')
async def index(request):
    return response.html('<p>Hello</p>')
```

When we try to import something non-existent, exception `ImportError` will be thrown,
[line 38 of __main__.py](https://github.com/channelcat/sanic/blob/5fd62098bd2f2722876a0873d5856d70046d3889/sanic/__main__.py#L38) does not preserve the exception, reporting preset message (what's provided on commandline) instead.  This is what we will get:

```
python -m sanic main.app
No module named main found.
  Example File: project/sanic_server.py -> app
  Example Module: project.sanic_server.app
```

It is very hard to find the true cause if the import statement that failed is, let's say, buried three levels of modules deep, for example.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sanic/__main__.py`
Content:
```
1 from argparse import ArgumentParser
2 from importlib import import_module
3 
4 from sanic.log import log
5 from sanic.app import Sanic
6 
7 if __name__ == "__main__":
8     parser = ArgumentParser(prog='sanic')
9     parser.add_argument('--host', dest='host', type=str, default='127.0.0.1')
10     parser.add_argument('--port', dest='port', type=int, default=8000)
11     parser.add_argument('--cert', dest='cert', type=str,
12                         help='location of certificate for SSL')
13     parser.add_argument('--key', dest='key', type=str,
14                         help='location of keyfile for SSL.')
15     parser.add_argument('--workers', dest='workers', type=int, default=1, )
16     parser.add_argument('--debug', dest='debug', action="store_true")
17     parser.add_argument('module')
18     args = parser.parse_args()
19 
20     try:
21         module_parts = args.module.split(".")
22         module_name = ".".join(module_parts[:-1])
23         app_name = module_parts[-1]
24 
25         module = import_module(module_name)
26         app = getattr(module, app_name, None)
27         if not isinstance(app, Sanic):
28             raise ValueError("Module is not a Sanic app, it is a {}.  "
29                              "Perhaps you meant {}.app?"
30                              .format(type(app).__name__, args.module))
31         if args.cert is not None or args.key is not None:
32             ssl = {'cert': args.cert, 'key': args.key}
33         else:
34             ssl = None
35 
36         app.run(host=args.host, port=args.port,
37                 workers=args.workers, debug=args.debug, ssl=ssl)
38     except ImportError:
39         log.error("No module named {} found.\n"
40                   "  Example File: project/sanic_server.py -> app\n"
41                   "  Example Module: project.sanic_server.app"
42                   .format(module_name))
43     except ValueError as e:
44         log.error("{}".format(e))
45
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sanic/__main__.py b/sanic/__main__.py
--- a/sanic/__main__.py
+++ b/sanic/__main__.py
@@ -35,10 +35,10 @@
 
         app.run(host=args.host, port=args.port,
                 workers=args.workers, debug=args.debug, ssl=ssl)
-    except ImportError:
+    except ImportError as e:
         log.error("No module named {} found.\n"
                   "  Example File: project/sanic_server.py -> app\n"
                   "  Example Module: project.sanic_server.app"
-                  .format(module_name))
+                  .format(e.name))
     except ValueError as e:
         log.error("{}".format(e))

{"golden_diff": "diff --git a/sanic/__main__.py b/sanic/__main__.py\n--- a/sanic/__main__.py\n+++ b/sanic/__main__.py\n@@ -35,10 +35,10 @@\n \n         app.run(host=args.host, port=args.port,\n                 workers=args.workers, debug=args.debug, ssl=ssl)\n-    except ImportError:\n+    except ImportError as e:\n         log.error(\"No module named {} found.\\n\"\n                   \"  Example File: project/sanic_server.py -> app\\n\"\n                   \"  Example Module: project.sanic_server.app\"\n-                  .format(module_name))\n+                  .format(e.name))\n     except ValueError as e:\n         log.error(\"{}\".format(e))\n", "issue": "__main__ top-level script shadowing ImportError\nGiven `main.py`:\r\n```python\r\nimport nonexistent  # assuming this is... non-existent\r\nfrom sanic import Sanic, response\r\n\r\n\r\napp = Sanic(__name__)\r\n\r\n\r\n@app.route('/')\r\nasync def index(request):\r\n    return response.html('<p>Hello</p>')\r\n```\r\n\r\nWhen we try to import something non-existent, exception `ImportError` will be thrown,\r\n[line 38 of __main__.py](https://github.com/channelcat/sanic/blob/5fd62098bd2f2722876a0873d5856d70046d3889/sanic/__main__.py#L38) does not preserve the exception, reporting preset message (what's provided on commandline) instead.  This is what we will get:\r\n\r\n```\r\npython -m sanic main.app\r\nNo module named main found.\r\n  Example File: project/sanic_server.py -> app\r\n  Example Module: project.sanic_server.app\r\n```\r\n\r\nIt is very hard to find the true cause if the import statement that failed is, let's say, buried three levels of modules deep, for example.\n", "before_files": [{"content": "from argparse import ArgumentParser\nfrom importlib import import_module\n\nfrom sanic.log import log\nfrom sanic.app import Sanic\n\nif __name__ == \"__main__\":\n    parser = ArgumentParser(prog='sanic')\n    parser.add_argument('--host', dest='host', type=str, default='127.0.0.1')\n    parser.add_argument('--port', dest='port', type=int, default=8000)\n    parser.add_argument('--cert', dest='cert', type=str,\n                        help='location of certificate for SSL')\n    parser.add_argument('--key', dest='key', type=str,\n                        help='location of keyfile for SSL.')\n    parser.add_argument('--workers', dest='workers', type=int, default=1, )\n    parser.add_argument('--debug', dest='debug', action=\"store_true\")\n    parser.add_argument('module')\n    args = parser.parse_args()\n\n    try:\n        module_parts = args.module.split(\".\")\n        module_name = \".\".join(module_parts[:-1])\n        app_name = module_parts[-1]\n\n        module = import_module(module_name)\n        app = getattr(module, app_name, None)\n        if not isinstance(app, Sanic):\n            raise ValueError(\"Module is not a Sanic app, it is a {}.  \"\n                             \"Perhaps you meant {}.app?\"\n                             .format(type(app).__name__, args.module))\n        if args.cert is not None or args.key is not None:\n            ssl = {'cert': args.cert, 'key': args.key}\n        else:\n            ssl = None\n\n        app.run(host=args.host, port=args.port,\n                workers=args.workers, debug=args.debug, ssl=ssl)\n    except ImportError:\n        log.error(\"No module named {} found.\\n\"\n                  \"  Example File: project/sanic_server.py -> app\\n\"\n                  \"  Example Module: project.sanic_server.app\"\n                  .format(module_name))\n    except ValueError as e:\n        log.error(\"{}\".format(e))\n", "path": "sanic/__main__.py"}], "after_files": [{"content": "from argparse import ArgumentParser\nfrom importlib import import_module\n\nfrom sanic.log import log\nfrom sanic.app import Sanic\n\nif __name__ == \"__main__\":\n    parser = ArgumentParser(prog='sanic')\n    parser.add_argument('--host', dest='host', type=str, default='127.0.0.1')\n    parser.add_argument('--port', dest='port', type=int, default=8000)\n    parser.add_argument('--cert', dest='cert', type=str,\n                        help='location of certificate for SSL')\n    parser.add_argument('--key', dest='key', type=str,\n                        help='location of keyfile for SSL.')\n    parser.add_argument('--workers', dest='workers', type=int, default=1, )\n    parser.add_argument('--debug', dest='debug', action=\"store_true\")\n    parser.add_argument('module')\n    args = parser.parse_args()\n\n    try:\n        module_parts = args.module.split(\".\")\n        module_name = \".\".join(module_parts[:-1])\n        app_name = module_parts[-1]\n\n        module = import_module(module_name)\n        app = getattr(module, app_name, None)\n        if not isinstance(app, Sanic):\n            raise ValueError(\"Module is not a Sanic app, it is a {}.  \"\n                             \"Perhaps you meant {}.app?\"\n                             .format(type(app).__name__, args.module))\n        if args.cert is not None or args.key is not None:\n            ssl = {'cert': args.cert, 'key': args.key}\n        else:\n            ssl = None\n\n        app.run(host=args.host, port=args.port,\n                workers=args.workers, debug=args.debug, ssl=ssl)\n    except ImportError as e:\n        log.error(\"No module named {} found.\\n\"\n                  \"  Example File: project/sanic_server.py -> app\\n\"\n                  \"  Example Module: project.sanic_server.app\"\n                  .format(e.name))\n    except ValueError as e:\n        log.error(\"{}\".format(e))\n", "path": "sanic/__main__.py"}]}