Revert "Removed the permission error checks"

This reverts commit 0c8600512dee692ef35ec556f3d6ed0f542e27d8.