1 Answer
1

If public read/write the __share sObject will not exist and your apex will fail to compile. You should consider using the global describe and dynamic apex to avoid this if you have to support sObjects that might be public read/write.

As far as telling public read only apart from private sharing I think your approach of attempting to insert a share record and looking at the resulting exception, if any, is the best approach I've seen to date.

Also note that if you're looking for access on a per-record basis you should look into the UserRecordAccess sObject, but it sounds like you're looking for org-wide defaults only, correct?