From 1aa2c29b86b1a3c9ce95e3c33f2f0f88f8dcd533 Mon Sep 17 00:00:00 2001 From: Victor Häggqvist Date: Fri, 9 May 2014 00:42:49 +0200 Subject: some what improved exception handling --- giti.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/giti.py b/giti.py index c01c652..0b431e0 100755 --- a/giti.py +++ b/giti.py @@ -5,7 +5,7 @@ import sys import urllib2 __author__ = 'Victor Häggqvist' -__version__ = 0.1 +__version__ = '0.1.1' def gitiglobal(type): @@ -16,8 +16,13 @@ def gitiglobal(type): try: gifile = urllib2.urlopen("https://raw.githubusercontent.com/github/gitignore/master/Global/"+type+".gitignore").read() store(gifile) - except: - print "Not found in global either" + except urllib2.HTTPError as e: + if e.code == 404: + print "Not found in global either" + else: + print "Got unexpected answer from Github, you better check on them..." + + def store(file): @@ -54,9 +59,14 @@ def giti(type): try: gifile = urllib2.urlopen("https://raw.githubusercontent.com/github/gitignore/master/"+type+".gitignore").read() store(gifile) - except: - print "not found in master" - gitiglobal(type) + except urllib2.HTTPError as e: + if e.code == 404: + print "Not found in master" + gitiglobal(type) + else: + print "Got unexpected answer from Github, you better check on them..." + + def main(): -- cgit v1.2.3