summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorTulio Casagrande <tcasagra@thoughtworks.com>2016-05-30 15:26:03 -0300
committerTulio Casagrande <tcasagra@thoughtworks.com>2016-05-30 15:26:03 -0300
commit3422846b2ef9677db857e3adde312b7fbbd4b068 (patch)
treec1430679cac2674c89c8db6c6a2b13d9a1a2ad1d /service
parent12c582b7e14e697c4ee0fbaaea2ed201eb779312 (diff)
Handle errors on started process
In single user-mode, the InvalidAuthTokenError may occur during initialization
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/application.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/service/pixelated/application.py b/service/pixelated/application.py
index af29bc5f..ce1e0258 100644
--- a/service/pixelated/application.py
+++ b/service/pixelated/application.py
@@ -14,12 +14,14 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+import os
import logging
from OpenSSL import SSL
from OpenSSL import crypto
from leap.common.events import (server as events_server,
register, catalog as events)
+from leap.soledad.common.errors import InvalidAuthTokenError
from twisted.cred import portal
from twisted.cred.checkers import AllowAnonymousAccess
from twisted.internet import defer
@@ -210,12 +212,20 @@ def _start_in_single_user_mode(args, resource, services_factory):
args.leap_provider_cert_fingerprint,
args.credentials_file,
args.leap_home)
- deferred.addCallback(
+
+ def _handle_error(exception):
+ if(exception.type is InvalidAuthTokenError):
+ log.critical('Got an invalid soledad token, the user agent can\'t synchronize data, exiting')
+ os._exit(1)
+ else:
+ exception.raiseException()
+
+ deferred.addCallbacks(
lambda leap_session: start_user_agent_in_single_user_mode(
resource,
services_factory,
args.leap_home,
- leap_session))
+ leap_session), _handle_error)
return deferred