From 8137b5067b107f44af4f1124b619fbfcbd0cdcb5 Mon Sep 17 00:00:00 2001 From: Pranav Jerry Date: Tue, 21 Sep 2021 22:43:41 +0530 Subject: [PATCH] made error messages more readable Not a big commit, so pushed directly to master --- CHANGELOG.md | 4 ++++ naxalnet/__init__.py | 2 +- naxalnet/default.py | 3 +++ naxalnet/scripts.py | 15 +++++++++++++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 642d99a..6b02b14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [Unreleased][] - 2021-09-21 + +- Better error messages + ## [v0.4.0][] - 2021-09-20 - naxalnet is now a daemon! naxalnet will reconfigure the WiFi network diff --git a/naxalnet/__init__.py b/naxalnet/__init__.py index 4fc72de..69dfb62 100644 --- a/naxalnet/__init__.py +++ b/naxalnet/__init__.py @@ -35,4 +35,4 @@ See README.md for documentation. # # In case you forgot to change the version, skip the number # and put the next number in the next commit. -__version__ = "0.4.0" +__version__ = "0.4.0a1" diff --git a/naxalnet/default.py b/naxalnet/default.py index 74c8076..ecf3570 100644 --- a/naxalnet/default.py +++ b/naxalnet/default.py @@ -38,3 +38,6 @@ CONFIG = { # glob CONFIG_FILES = ["naxalnet.conf", "naxalnet.conf.d/*.conf"] CONFIG_DIRS = ["/usr/share/naxalnet", "/usr/local/share/naxalnet", "/etc/naxalnet"] + +ISSUE_URL = "https://git.disroot.org/pranav/naxalnet/issues" +REPORT_BUG_INFO = "If you think this is a bug, report it to " + ISSUE_URL diff --git a/naxalnet/scripts.py b/naxalnet/scripts.py index 5594786..e201ca1 100644 --- a/naxalnet/scripts.py +++ b/naxalnet/scripts.py @@ -32,6 +32,7 @@ from shutil import copy from dasbus.error import DBusError from systemd.daemon import notify from naxalnet import __version__ +from naxalnet.default import REPORT_BUG_INFO from naxalnet.log import logger from naxalnet.iwd import Adapter, Device, IWD from naxalnet.config import args @@ -57,8 +58,13 @@ def copy_files(): # Copy all files in src to dest for i in src.iterdir(): copy(i, dest) - except PermissionError as error: - logger.error("Cannot copy file: %s", error) + except PermissionError: + logger.exception("A PermissionError occured while copying files") + logger.error(REPORT_BUG_INFO) + sys.exit(3) + except: + logger.exception("An unknown error occured while copying files") + logger.error(REPORT_BUG_INFO) sys.exit(3) @@ -129,6 +135,11 @@ def setup_devices(): except DBusError: logger.exception("Error while communicating with iwd") + logger.error(REPORT_BUG_INFO) + sys.exit(4) + except: + logger.exception("An unknow error occured while setting up the mesh") + logger.error(REPORT_BUG_INFO) sys.exit(4)