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

How can I access the errors that occur during import? #189

Closed
WelliSolutions opened this issue Dec 16, 2023 · 2 comments
Closed

How can I access the errors that occur during import? #189

WelliSolutions opened this issue Dec 16, 2023 · 2 comments

Comments

@WelliSolutions
Copy link

When opening an AASX file, some errors are reported and printed to console, but there's no exception thrown.

Example:
an AASX file made with Package Explorer suffering from Bug 681 results in the following output.

ValueError: {https://admin-shell.io/aas/3/0}reference on line 12 is of type <class 'basyx.aas.model.base.ExternalReference'>, expected <class 'basyx.aas.model.base.ModelReference'>!
 -> Failed to construct {https://admin-shell.io/aas/3/0}reference on line 12 using _construct_submodel_reference!

Even if a ValueError is reported, I get an object_store and no exception is thrown.

Some other errors result in an exception, e.g. an AASX file made with Package Explorer suffering from Bug 666 throws a ValueError which I can catch.

My code is the same in both cases:

    def open(self, filename: str) -> model.DictObjectStore[model.Identifiable]:
        object_store: model.DictObjectStore[model.Identifiable] = model.DictObjectStore()
        file_store: aasx.DictSupplementaryFileContainer = aasx.DictSupplementaryFileContainer()
        with aasx.AASXReader(filename) as reader:
            reader.read_into(object_store=object_store, file_store=file_store)
        return object_store

How can I find out that there were errors during import?

@jkhsjdhjs
Copy link
Contributor

You can pass failsafe=False as additional keyword argument to reader.read_into(). This sadly isn't properly documented.

@WelliSolutions
Copy link
Author

Thank you. Very helpful parameter for detecting and dealing with those bugs.

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