Skip to content

Commit

Permalink
webserve: Clean up exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rn3j committed Nov 26, 2024
1 parent 4d6a1d9 commit 5f95043
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/tauon/t_modules/t_webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,11 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
tauon.radio_server = httpd
httpd.serve_forever()
httpd.server_close()
except OSError:
logging.exception("Not starting radio page server, another Tauon instance already running?")
except OSError as e:
if str(e) == "[Errno 98] Address already in use":
logging.error("Not starting radio page server, is another Tauon instance already running?")
else:
logging.exception("Unknown OSError starting radio page server!")
except Exception:
logging.exception("Failed starting radio page server!")

Expand Down Expand Up @@ -677,10 +680,13 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
httpd = ThreadedHTTPServer(("0.0.0.0", 7814), Server)
httpd.serve_forever()
httpd.server_close()
except OSError:
logging.exception("Not starting web api server, already running?")
except OSError as e:
if str(e) == "[Errno 98] Address already in use":
logging.error("Not starting web api server, is another Tauon instance already running?")
else:
logging.exception("Unknown OSError starting web api server!")
except Exception:
logging.exception("Failed starting radio page server!")
logging.exception("Failed starting web api server!")


def controller(tauon: Tauon) -> None:
Expand Down Expand Up @@ -731,9 +737,9 @@ def do_GET(self) -> None:
if str(e) == "[Errno 98] Address already in use":
logging.error("Not starting controller webserver, is another Tauon instance already running?")
else:
logging.exception("Unknown OSError starting radio page server!")
logging.exception("Unknown OSError starting controller server!")
except Exception:
logging.exception("Failed starting radio page server!")
logging.exception("Failed starting controller server!")


def authserve(tauon: Tauon) -> None:
Expand Down

0 comments on commit 5f95043

Please sign in to comment.