With what you are trying, it's not possible. Not all Objects have an associated Share object, so it's not possible to access a property which does not exist. E.g., an object on detail side of a master-detail relationship doesn't have one. You will need to address this on case by case basis.
Excerpt from Sharing a Record Using Apex:
Objects on the detail side of a master-detail relationship do not have an associated sharing object. The detail record’s access is determined by the master’s sharing object and the relationship’s sharing setting.
Additionally the same documentation mentions:
Sharing granted to users implicitly through organization-wide defaults, the role hierarchy, and permissions such as the “View All” and “Modify All” permissions for the given object, “View All Data,” and “Modify All Data” are not tracked with this object.