Raise exception instead of using assert

This commit is contained in:
shortcutme 2019-07-03 18:35:55 +02:00
parent 80bfccd9d3
commit ff32f822ba
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
7 changed files with 27 additions and 12 deletions

View file

@ -137,7 +137,9 @@ class UiWebsocketPlugin(object):
@PluginManager.registerTo("User")
class UserPlugin(object):
def getEncryptPrivatekey(self, address, param_index=0):
assert param_index >= 0 and param_index <= 1000
if param_index < 0 or param_index > 1000:
raise Exception("Param_index out of range")
site_data = self.getSiteData(address)
if site_data.get("cert"): # Different privatekey for different cert provider
@ -153,7 +155,9 @@ class UserPlugin(object):
return site_data["encrypt_privatekey_%s" % index]
def getEncryptPublickey(self, address, param_index=0):
assert param_index >= 0 and param_index <= 1000
if param_index < 0 or param_index > 1000:
raise Exception("Param_index out of range")
site_data = self.getSiteData(address)
if site_data.get("cert"): # Different privatekey for different cert provider