PyRx icon indicating copy to clipboard operation
PyRx copied to clipboard

C++ Exceptions

Open CEXT-Dan opened this issue 5 months ago • 0 comments

Discussed in https://github.com/CEXT-Dan/PyRx/discussions/109

Originally posted by gswifort September 5, 2024 To make working with C++ exceptions easier I added tools to translate general C++ exceptions (RuntimeError) to specific types. You can see the implementation here. Usage looks like this:

text = Db.Text()
text_id = db.addToModelspace(text)
with cast_to_arx_exception:
    Db.Text(text_id, Db.OpenMode.kForRead)  # raises pyrx.exceptions.eWasOpenForWrite

I wonder if I should stick to this path or if you have a better idea..? Maybe you want to implement something similar in C++?

CEXT-Dan avatar Sep 05 '24 23:09 CEXT-Dan