Skip to content

Commit bf56521

Browse files
committed
Create Tunnel.TunnelError for specialized errors in that file
1 parent 16a1af6 commit bf56521

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

meshtastic/tunnel.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ def onTunnelReceive(packet, interface): # pylint: disable=W0613
3838
class Tunnel:
3939
"""A TUN based IP tunnel over meshtastic"""
4040

41+
class TunnelError(Exception):
42+
"""An exception class for general tunnel errors"""
43+
def __init__(self, message):
44+
self.message = message
45+
super().__init__(self.message)
46+
4147
def __init__(self, iface, subnet="10.115", netmask="255.255.0.0"):
4248
"""
4349
Constructor
@@ -47,19 +53,19 @@ def __init__(self, iface, subnet="10.115", netmask="255.255.0.0"):
4753
"""
4854

4955
if not iface:
50-
raise Exception("Tunnel() must have a interface")
56+
raise Tunnel.TunnelError("Tunnel() must have a interface")
5157

5258
if not subnet:
53-
raise Exception("Tunnel() must have a subnet")
59+
raise Tunnel.TunnelError("Tunnel() must have a subnet")
5460

5561
if not netmask:
56-
raise Exception("Tunnel() must have a netmask")
62+
raise Tunnel.TunnelError("Tunnel() must have a netmask")
5763

5864
self.iface = iface
5965
self.subnetPrefix = subnet
6066

6167
if platform.system() != "Linux":
62-
raise Exception("Tunnel() can only be run instantiated on a Linux system")
68+
raise Tunnel.TunnelError("Tunnel() can only be run instantiated on a Linux system")
6369

6470
our_globals = Globals.getInstance()
6571
our_globals.set_tunnelInstance(self)

0 commit comments

Comments
 (0)