aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Häggqvist <[email protected]>2014-05-09 00:42:49 +0200
committerVictor Häggqvist <[email protected]>2014-05-09 00:42:49 +0200
commit1aa2c29b86b1a3c9ce95e3c33f2f0f88f8dcd533 (patch)
treef8d9bb3120f406fac8c7d2c3d6e3293001a25bbf
parent56dded948eb2100fb9d6bafde9689916af057e32 (diff)
some what improved exception handling
-rwxr-xr-xgiti.py22
1 files 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():