Skip to content

Commit

Permalink
Remove bare exception handlers.
Browse files Browse the repository at this point in the history
It's better to print out the traceback, so that it's easier to debug
what's wrong.
  • Loading branch information
Bjorn Tillenius committed Feb 15, 2008
1 parent 36f216a commit 08ea5e1
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions pygarmin
Expand Up @@ -53,13 +53,8 @@ class Arguments(list):
if n > self.maxlength:
self.maxlength = n

try:
parsed, leftover = getopt.getopt(sys.argv[1:], ''.join(shortopts),
longopts)
except:
print '%s: %s' % (sys.argv[0], sys.exc_info()[1])
sys.exit(1)

parsed, leftover = getopt.getopt(sys.argv[1:], ''.join(shortopts),
longopts)
for option, value in parsed:
if option.startswith('--'):
option = option[2:]
Expand Down Expand Up @@ -153,24 +148,14 @@ The default command is to display the product information.
'info', 'protocols', 'waypoints', 'routes', 'tracks', 'laps',
'runs')
if cmd in available_commands:
try:
getattr(self, cmd)()
except:
c, e = sys.exc_info()[0:2]
print "%s: %s" % (c, e)
sys.exit(-1)
getattr(self, cmd)()

def device(self, arg):
if arg.lower() == 'usb:':
link = garmin.USBLink()
else:
link = garmin.SerialLink(arg)
try:
self.gps = garmin.Garmin(link)
except:
c, e = sys.exc_info()[0:2]
print "%s: %s" % (c, e)
sys.exit(-1)
self.gps = garmin.Garmin(link)

### commands

Expand Down

0 comments on commit 08ea5e1

Please sign in to comment.