Skip to content
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

Improve code generation user-facing error on non-existent source file #955

Closed
fleimgruber opened this issue Feb 22, 2024 · 4 comments
Closed

Comments

@fleimgruber
Copy link

When referencing a non-existent source file ("non-existing.xsd"):

xsdata generate non-existing.xsd --package some.models -ss single-package

only a CodeGenerationError is shown:

========= xsdata v24.2.1 / Python 3.10.8 / Platform win32 =========

Traceback (most recent call last):
...
xsdata.exceptions.CodeGenerationError: Nothing to generate.

when instead a FileNotFoundError would be more informative for the user.

@fleimgruber
Copy link
Author

@tefra If you think this is a good change then I will create a PR for it.

@tefra
Copy link
Owner

tefra commented Feb 22, 2024

The transformer is very lenient and doesn't fail if an included schema can't be retrieved, but yes I agree that behavior shouldn't be extended to the main resource file

@fleimgruber
Copy link
Author

@tefra could you give me a quick heads up please on where this is best tested? I looked at the testing and exceptions seem to be captured and printed to the user? Assuming that is true, I went to test for process output (i.e. not testing with assertRaises) of runner invocation results and could not find the expected traceback containing xsdata.exceptions.CodeGenerationError as in OP, but only the line ========= xsdata v24.2.1 / Python 3.10.8 / Platform win32 =========. Please see also fleimgruber@41ce482.

@tefra
Copy link
Owner

tefra commented Mar 9, 2024

A proper warning will now be generated

❯ xsdata generate i/dont/exists.wsdl
========= xsdata v24.2.1 / Python 3.11.4+ / Platform linux =========

Warnings: 1
warning: Resource not found file:///home/chris/projects/xsdata/i/dont/exists.wsdl
~/projects/xsdata nicer-cli-errors *3 ❯     

@tefra tefra closed this as completed Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants