Fix: Stop swallowing ImportError when loading micro simulation#265
Fix: Stop swallowing ImportError when loading micro simulation#265Geethapranay1 wants to merge 2 commits into
Conversation
|
@IshaanDesai PTAL! |
|
@fsimonis can you please test this with the foamlib case? |
|
This works, but doesn't give additional context. |
Okay. So the |
|
@fsimonis could you clarify what context you'd expect? I can catch the |
|
This is the output: My propsed fix in #262 results in: I'm fine with both. |
|
@fsimonis thanks for testing this and sharing the comparison with #262, really helpful |
|
@Geethapranay1 I merged the solution proposed by @fsimonis. From your contribution, the tests could still be valuable. Can you please merge the upstream develop branch into your branch and then reformulate the tests? |
|
@IshaanDesai Before I rebase the tests, i noted that on #262 error handling wrapping ModuleNotFoundError in RuntimeError drops the .name attribute and exception type, which means callers can't programmatically distinguish a missing dependency from other runtime failures may be re-raising as ModuleNotFoundError(...) from e preserves both the type and the causal chain while still adding the contextual message and also there is a minor typo error "Counld" -> "Could" typo on l623. i will include this fix alongside the tests and happy to take a opinion on the RuntimeError |
Fix #258
Previously,
load_backend_classswallowedImportErrorinside thetry_loadblock. This hid the real error (like a missing dependency such asfoamlib) and just threw a generic "Could not load micro simulation" error.I moved the
import_modulecall out of thetry...exceptblock so thatModuleNotFoundErrorbubbles up properly. I also added some tests to verify that missing direct and transitive dependencies report the correct error, while making sure the old fallback logic still works if the file loads but the class is missingChecklist:
CHANGELOG.md.