Sharing group shares stable7

backport of https://github.com/owncloud/core/pull/10107. I just want to give Jenkins the chance to test it before we merge it to stable7.
The advantage of throwing you own exception is that you can define it as you wish. E.g with different error codes to indicate to problem more directly then a generic exception. But I could probably use the class mentioned by you as base class.