[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/master] circuitbuilder: Stop raising exception on path invalid.
commit 0773f09038b9422872302347df2ad52263f351e3
Author: juga0 <juga@xxxxxxxxxx>
Date: Wed Feb 6 17:15:19 2019 +0000
circuitbuilder: Stop raising exception on path invalid.
Instead, return the reason why the circuit could not be built,
as other errors do.
---
sbws/lib/circuitbuilder.py | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/sbws/lib/circuitbuilder.py b/sbws/lib/circuitbuilder.py
index 8efc8de..be10c2b 100644
--- a/sbws/lib/circuitbuilder.py
+++ b/sbws/lib/circuitbuilder.py
@@ -7,15 +7,6 @@ import logging
log = logging.getLogger(__name__)
-class PathLengthException(Exception):
- def __init__(self, message=None, errors=None):
- if message is not None:
- super().__init__(message)
- else:
- super().__init__()
- self.errors = errors
-
-
def valid_circuit_length(path):
return 0 < len(path) <= 8
@@ -66,7 +57,7 @@ class CircuitBuilder:
was an error building the circuit.
"""
if not valid_circuit_length(path):
- raise PathLengthException()
+ return None, "Can not build a circuit, invalid path."
c = self.controller
timeout = self.circuit_timeout
fp_path = '[' + ' -> '.join([p for p in path]) + ']'
@@ -142,7 +133,7 @@ class GapsCircuitBuilder(CircuitBuilder):
chosen uniformally at random. A relay will not be in a circuit twice.
'''
if not valid_circuit_length(path):
- raise PathLengthException()
+ return None, "Can not build a circuit, invalid path."
path = self._normalize_path(path)
if path is None:
return None
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits