get-perms-api-helper: show nicer message when prefix is specified to help in API usage.

This commit is contained in:
Marcin Kuzminski 2020-01-14 16:15:13 +01:00
parent 2c14a575a7
commit abcf0ed683
6 changed files with 11 additions and 8 deletions

View file

@ -308,7 +308,11 @@ def get_perm_or_error(permid, prefix=None):
perm = PermissionModel.cls.get_by_key(permid)
if perm is None:
raise JSONRPCError('permission `%s` does not exist' % (permid,))
msg = 'permission `{}` does not exist.'.format(permid)
if prefix:
msg += ' Permission should start with prefix: `{}`'.format(prefix)
raise JSONRPCError(msg)
if prefix:
if not perm.permission_name.startswith(prefix):
raise JSONRPCError('permission `%s` is invalid, '