Improving error handling to enable better debug of permission related exceptions.