tensorflow / swift

Swift for TensorFlow
https://tensorflow.org/swift
Apache License 2.0
6.13k stars 606 forks source link

Throwing and Import #592

Closed jhawgs closed 3 years ago

jhawgs commented 3 years ago

I have a block of code that is reliant upon receiving import errors. Specifically, when attempting to import a non-existent module, I want to be able to catch the import error instead of having the application crash. I tried to use throwing consistently with the Python Interoperability doc, like so:

do { let nonExistentModule: PythonObject = try Python.import.throwing("non_existent_module") } catch { // handle error }

It returns:

Value of type '(String) -> PythonObject' has no member 'throwing'

Is this implemented differently for import, or is this capability not supported?