Skip to content
Snippets Groups Projects
Commit 8d67d3a2 authored by Henke Adolfsson's avatar Henke Adolfsson
Browse files

Update exception handling by printing a message

parent fbfb939b
Branches
Tags
Loading
...@@ -4,7 +4,9 @@ import configparser ...@@ -4,7 +4,9 @@ import configparser
class FindRootException(Exception): class FindRootException(Exception):
pass
def __init__(self, message):
self.message = message
def _IsKattisDirectory(path): def _IsKattisDirectory(path):
......
...@@ -10,7 +10,9 @@ HEADERS = { ...@@ -10,7 +10,9 @@ HEADERS = {
} }
class LoginError(Exception): class LoginError(Exception):
pass
def __init__(self, message):
self.message = message
def _GetFilesWithExtensions(bus, problemname, exts): def _GetFilesWithExtensions(bus, problemname, exts):
...@@ -28,7 +30,7 @@ def _GetFilesWithExtensions(bus, problemname, exts): ...@@ -28,7 +30,7 @@ def _GetFilesWithExtensions(bus, problemname, exts):
def _GetUserConfig(bus): def _GetUserConfig(bus):
configfile = bus.call('kattcmd:config:load-user', bus, 'kattisrc') configfile = bus.call('kattcmd:config:load-user', bus, 'kattisrc')
if not configfile or not os.path.isfile(configfile): 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 = configparser.ConfigParser()
config.read(configfile) config.read(configfile)
return config return config
......
...@@ -50,4 +50,11 @@ def main(): ...@@ -50,4 +50,11 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
try:
main() main()
except Exception as e:
print(dir(e))
if hasattr(e, 'message'):
print(e.message)
else:
print(e)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment