Skip to content

Commit dd5f6f8

Browse files
djonssonwaldyrious
authored andcommitted
Added exception handling to main (tldr-pages#28)
This allows showing a more user friendly error message when internet connection is missing.
1 parent 00b45bc commit dd5f6f8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tldr.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,13 @@ def main():
278278
options = parser.parse_args(other_options)
279279

280280
for command in options.command:
281-
if options.os is not None:
282-
output(get_page(command, options.os))
283-
284-
else:
285-
output(get_page(command))
281+
try:
282+
if options.os is not None:
283+
output(get_page(command, options.os))
284+
else:
285+
output(get_page(command))
286+
except Exception:
287+
print("No internet connection detected. Please reconnect and try again.")
286288

287289

288290
if __name__ == "__main__":

0 commit comments

Comments
 (0)