New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More sensible error message for runscript #955
Comments
Hey @Deleetdk, I have just been looking through this and I would like to tackle it. Sorry for the bad experience you had to go through to discover this bug. After looking into it, I think the error message for a non-existent script is correct. I think the error message for when there's an import error in the script is what needs to be fixed. However, you will notice that when the invalid import is placed inside the def run():
import nonexistent
print("Test") Exception:
I think this is what should be raised when there is an invalid import. |
Makes sense. However, I didn't know that I had to put my imports inside |
@Deleetdk that's not the recommended way to do it. I just tried it out and noticed it handled the error correctly. |
Resolves django-extensions#955 - When a missing import is found in a script, this changes the error message displayed to indicate that there's a missing import, rather than giving a generic error message similar to the one raised when the script does not exist
The imports inside the Thanks to @kevgathuku we have #964 now ! |
Would be cool if we could get test cases as well for this to avoid regressions in the future. |
The error info is confusing.
Reason:
How to fix it:
# runscript file:
def run():
try:
from xxx import xxx # maybe the third party package has bugs.
do_xxx()
except Exception as e:
print(e)
raise e
|
Hi guys, I'm not sure wether open a new issue for that, but: The solution of this issue -- a
Then you are still getting:
It should either just run, or you should get something like:
Similar situation is when you have your script under:
and you are trying to run:
From the usability point of view, it should either just run, or it should inform the user that, e.g.:
People (including me) are still having problems with that, see, e.g.: https://stackoverflow.com/a/67440238/8877692 |
I wasted a lot of time discovering that runscript gives the same error message for when there is an import error in the script and when it cannot find the script at all. Please add a check for whether the file exists at all first, and throw a distinct error if it cannot find any such script.
StackOverflow example.
The text was updated successfully, but these errors were encountered: