Repository: sanic-org/sanic

Issue:
Circular import in target file accidentally triggers 'No module named ... found'
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

While developing it appears that I accidentally caused a circular import which Python traces back to starting in the file I have my app in. As a result, Python outputs an error such as the following:
```
ImportError: cannot import name 'constants' from partially initialized module 'app' (most likely due to a circular import) (/api/app/__init__.py)
```
In this case my module I pass to the sanic server is `app:app`, from within `/api`.

### Code snippet

_No response_

### Expected Behavior

I had this in the back of my mind the entire time, but found it very difficult to troubleshoot due to Sanic swallowing the error. As a result I ended up the rabbit hole of accidental breaking changes and tried commenting out different changes. An hour later I finally found the right import.

It would help if Sanic continued to output the specific import error, on the off-chance that it isn't an incorrectly setup module. The alternative would be to use more fine-grained `importlib` and manually call some functions rather than use their help functions. As a result there should be a different call which finds the file (an `ImportError` here hints at an incorrectly setup module), than the one which loads it (user error).

### How do you run Sanic?

Sanic CLI

### Operating System

Windows (Docker, Python:3.11)

### Sanic Version

23.3

### Additional context

_No response_
Circular import in target file accidentally triggers 'No module named ... found'
### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

While developing it appears that I accidentally caused a circular import which Python traces back to starting in the file I have my app in. As a result, Python outputs an error such as the following:
```
ImportError: cannot import name 'constants' from partially initialized module 'app' (most likely due to a circular import) (/api/app/__init__.py)
```
In this case my module I pass to the sanic server is `app:app`, from within `/api`.

### Code snippet

_No response_

### Expected Behavior

I had this in the back of my mind the entire time, but found it very difficult to troubleshoot due to Sanic swallowing the error. As a result I ended up the rabbit hole of accidental breaking changes and tried commenting out different changes. An hour later I finally found the right import.

It would help if Sanic continued to output the specific import error, on the off-chance that it isn't an incorrectly setup module. The alternative would be to use more fine-grained `importlib` and manually call some functions rather than use their help functions. As a result there should be a different call which finds the file (an `ImportError` here hints at an incorrectly setup module), than the one which loads it (user error).

### How do you run Sanic?

Sanic CLI

### Operating System

Windows (Docker, Python:3.11)

### Sanic Version

23.3

### Additional context

_No response_


Discussion:

Resolving patch:
diff --git a/sanic/cli/app.py b/sanic/cli/app.py
--- a/sanic/cli/app.py
+++ b/sanic/cli/app.py
@@ -180,6 +180,10 @@ def _get_app(self, app_loader: AppLoader):
                     "  Example File: project/sanic_server.py -> app\n"
                     "  Example Module: project.sanic_server.app"
                 )
+                error_logger.error(
+                    "\nThe error below might have caused the above one:\n"
+                    f"{e.msg}"
+                )
                 sys.exit(1)
             else:
                 raise e


Test patch: