summaryrefslogtreecommitdiff
path: root/lib/commands.py
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-08-22 10:43:46 +0200
committerSanto Cariotti <sancn@live.com>2017-08-22 10:43:46 +0200
commita9734c6146b6588244406578930cd4f0a061ad4c (patch)
treeeec168a5d7892d6d64357532f6ecf166c7f57ae7 /lib/commands.py
parent8ee6331c0e8105134c0ac29cd4fceecd2968f89b (diff)
fixed exceptions
Diffstat (limited to 'lib/commands.py')
-rw-r--r--lib/commands.py26
1 files changed, 9 insertions, 17 deletions
diff --git a/lib/commands.py b/lib/commands.py
index db464fe..ced0f3c 100644
--- a/lib/commands.py
+++ b/lib/commands.py
@@ -24,10 +24,8 @@ class Commands(object):
print('Ok')
elif cmd[1] is not ListCommands.commands['set']:
raise KeyError
- except IndexError:
- ListCommands.err('wrong')
- except KeyError:
- ListCommands.err('keyword')
+ except (IndexError, KeyError) as e:
+ ListCommands.err(type(e).__name__)
except PersonalError as e:
ListCommands.err('personal', e.value)
elif what == 'get':
@@ -43,7 +41,7 @@ class Commands(object):
else:
print('nil')
elif cmd[2] not in ListCommands.commands['get'][1]: #check if the word after 'i' exists
- ListCommands.err('keyword')
+ raise KeyError
else:
print(co[cmd[2]])
elif cmd[1] == 'todo':
@@ -63,10 +61,8 @@ class Commands(object):
print(count.decode('utf-8'))
else:
raise KeyError
- except IndexError:
- ListCommands.err('wrong')
- except KeyError:
- ListCommands.err('keyword')
+ except (IndexError, KeyError) as e:
+ ListCommands.err(type(e).__name__)
except PersonalError as e:
ListCommands.err('personal', e.value)
elif what == 'add':
@@ -84,10 +80,8 @@ class Commands(object):
print('Ok')
except:
raise KeyError
- except IndexError:
- ListCommands.err('wrong')
- except KeyError:
- ListCommands.err('keyword')
+ except (IndexError, KeyError):
+ ListCommands.err(type(e).__name__)
elif what == 'del':
try:
if len(cmd) > ListCommands.info['del'][1]:
@@ -105,10 +99,8 @@ class Commands(object):
print('Ok')
except Exception as e:
print(e)
- except IndexError:
- ListCommands.err('wrong')
- except KeyError:
- ListCommands.err('keyword')
+ except (IndexError, KeyError) as e:
+ ListCommands.err(type(e).__name__)
def msgFromId(value):