fixed error shown to user

This commit is contained in:
Adolfo Gómez García 2020-03-02 18:58:24 +01:00
parent 1d807784d2
commit 099a9ba3c1
2 changed files with 6 additions and 3 deletions

View File

@ -79,12 +79,14 @@ class Client(Handler):
"""
result = result if result is not None else ''
res = {'result': result}
if error is not None:
if error:
if isinstance(error, int):
error = errors.errorString(error)
error = str(error) # Ensure error is an string
if errorCode != 0:
error += ' (code {0:04X})'.format(errorCode)
# Reformat error so it is better understood by users
# error += ' (code {0:04X})'.format(errorCode)
error = _('Your service is being created. Please, wait while we complete it.)') + '({}%)'.format(int(errorCode * 25))
res['error'] = error
res['retryable'] = '1' if retryable else '0'

View File

@ -127,7 +127,8 @@ def userServiceEnabler(request: 'HttpRequest', idService: str, idTransport: str)
except ServiceNotReadyError as e:
logger.debug('Service not ready')
# Not ready, show message and return to this page in a while
error += ' (code {0:04X})'.format(e.code)
# error += ' (code {0:04X})'.format(e.code)
error = _('Your service is being created, please, wait for a few seconds while we complete it.)') + '({}%)'.format(int(e.code * 25))
except MaxServicesReachedError:
logger.info('Number of service reached MAX for service pool "%s"', idService)
error = errors.errorString(errors.MAX_SERVICES_REACHED)