made error messages more readable

Not a big commit, so pushed directly to master
This commit is contained in:
Pranav Jerry 2021-09-21 22:43:41 +05:30
parent 5f7c59d4b8
commit 8137b5067b
Signed by: pranav
GPG Key ID: F1DCDC4FED0A0C5B
4 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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)