From 79d4675f5bd26900f7e1fd4a1422e5e4d1475ca3 Mon Sep 17 00:00:00 2001 From: Kunihiko Kido Date: Thu, 7 May 2015 12:12:10 +0900 Subject: [PATCH] Added Show error message --- Lib/elasticsearch/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/elasticsearch/__init__.py b/Lib/elasticsearch/__init__.py index 498c8b2..68749b7 100644 --- a/Lib/elasticsearch/__init__.py +++ b/Lib/elasticsearch/__init__.py @@ -1,3 +1,4 @@ +import sublime import requests from .cat import CatClient from .indices import IndicesClient @@ -25,8 +26,13 @@ def request(self, method, path, body=None, params=None): if body is not None: body = body.encode('utf-8') - response = requests.request( - method.lower(), url, data=body, headers=self.headers) + try: + response = requests.request( + method.lower(), url, data=body, headers=self.headers) + except requests.exceptions.RequestException as e: + import sys + sublime.error_message("Error: {0!s}".format(e)) + sys.exit(1) return response