In your example here you do not have any try around it but check the retval while here you do not check the return value but rather wrap it in a try catch.
Which one is correct?
The native API shouldn’t throw exceptions*, but the Python wrapper might (e.g. when passed arguments are of incompatible types).
*One remote possibility is if there is an internal error. Normally they’re fatal but under IDAPython they’re converted to Python exceptions.