Skip to content

Commit 9f6579d

Browse files
committed
Showing exception message if it fails to take screenshot
1 parent 8cb4c95 commit 9f6579d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

getgauge/registry.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import re
34
import tempfile
45
from subprocess import call
@@ -141,15 +142,14 @@ def _take_screenshot():
141142
temp_file = os.path.join(tempfile.gettempdir(), 'screenshot.png')
142143
try:
143144
call(['gauge_screenshot', temp_file])
145+
_file = open(temp_file, 'r+b')
146+
data = _file.read()
147+
_file.close()
148+
return data
149+
except Exception as err:
150+
print(Fore.RED + "\nFailed to take screenshot using gauge_screenshot.\n{0}".format(err))
144151
except:
145-
pass
146-
if not os.path.exists(temp_file):
147-
print(Fore.RED + "Failed to take screenshot using gauge_screenshot.")
148-
return str.encode("")
149-
_file = open(temp_file, 'r+b')
150-
data = _file.read()
151-
_file.close()
152-
return data
153-
152+
print(Fore.RED + "\nFailed to take screenshot using gauge_screenshot.\n{0}".format(sys.exc_info()[0]))
153+
return str.encode("")
154154

155155
registry = Registry()

0 commit comments

Comments
 (0)