From 8d67d3a28a998ea9a0736807f1ef2bca37ebee08 Mon Sep 17 00:00:00 2001
From: Henke Adolfsson <catears13@gmail.com>
Date: Tue, 13 Mar 2018 07:05:34 +0100
Subject: [PATCH] Update exception handling by printing a message

---
 kattcmd/commands/root.py   | 4 +++-
 kattcmd/commands/submit.py | 6 ++++--
 kattcmd/main.py            | 9 ++++++++-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/kattcmd/commands/root.py b/kattcmd/commands/root.py
index 7e60f6a..db62a83 100644
--- a/kattcmd/commands/root.py
+++ b/kattcmd/commands/root.py
@@ -4,7 +4,9 @@ import configparser
 
 
 class FindRootException(Exception):
-    pass
+
+    def __init__(self, message):
+        self.message = message
 
 
 def _IsKattisDirectory(path):
diff --git a/kattcmd/commands/submit.py b/kattcmd/commands/submit.py
index 1970522..c34b2c4 100644
--- a/kattcmd/commands/submit.py
+++ b/kattcmd/commands/submit.py
@@ -10,7 +10,9 @@ HEADERS = {
 }
 
 class LoginError(Exception):
-    pass
+
+    def __init__(self, message):
+        self.message = message
 
 
 def _GetFilesWithExtensions(bus, problemname, exts):
@@ -28,7 +30,7 @@ def _GetFilesWithExtensions(bus, problemname, exts):
 def _GetUserConfig(bus):
     configfile = bus.call('kattcmd:config:load-user', bus, 'kattisrc')
     if not configfile or not os.path.isfile(configfile):
-        raise LoginError('No .kattisrc file present')
+        raise LoginError('No .kattisrc file present. Make sure to download it')
     config = configparser.ConfigParser()
     config.read(configfile)
     return config
diff --git a/kattcmd/main.py b/kattcmd/main.py
index 45ff55d..ce73a70 100644
--- a/kattcmd/main.py
+++ b/kattcmd/main.py
@@ -50,4 +50,11 @@ def main():
 
 
 if __name__ == '__main__':
-    main()
+    try:
+        main()
+    except Exception as e:
+        print(dir(e))
+        if hasattr(e, 'message'):
+            print(e.message)
+        else:
+            print(e)
-- 
GitLab