Skip to content

Commit 712684c

Browse files
committed
addressing comments on the pull request, modifying the exception statements to be more meaningful while also optimising the code
1 parent 668b282 commit 712684c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/python/plotly/plotly/io/_base_renderers.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,14 @@ def open_html_in_browser(html, using=None, new=0, autoraise=True):
670670
html = html.encode("utf8")
671671

672672
if isinstance(using, tuple):
673-
using = [i for i in webbrowser._browsers.keys() if any(j in i for j in using)][
674-
0
675-
]
673+
try:
674+
using = [i for i in webbrowser._browsers.keys() if i in using][0]
675+
except IndexError:
676+
raise ValueError(
677+
"""
678+
Unable to find the given browser.
679+
Try one among the following 'chrome', 'chromium', 'firefox' or 'default' """
680+
)
676681

677682
class OneShotRequestHandler(BaseHTTPRequestHandler):
678683
def do_GET(self):

0 commit comments

Comments
 (0)