Better handling of errors for check write permission