Skip to content

Commit f98e790

Browse files
committed
do not catch exception
1 parent 6c42716 commit f98e790

File tree

1 file changed

+7
-37
lines changed

1 file changed

+7
-37
lines changed

httpdbg/hooks/socket.py

+7-37
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,7 @@ def hook(self, buffer, *args, **kwargs):
184184
f"RECV_INTO - self={self} id={id(self)} socketdata={socketdata} args={args} kwargs={kwargs}"
185185
)
186186

187-
try:
188-
nbytes = method(self, buffer, *args, **kwargs)
189-
except Exception as ex:
190-
if socketdata and socketdata.record:
191-
socketdata.record.exception = ex
192-
raise
187+
nbytes = method(self, buffer, *args, **kwargs)
193188

194189
if socketdata:
195190
if socketdata.record:
@@ -241,12 +236,7 @@ def hook(self, bufsize, *args, **kwargs):
241236
f"RECV - self={self} id={id(self)} socketdata={socketdata} bufsize={bufsize} args={args} kwargs={kwargs}"
242237
)
243238

244-
try:
245-
buffer = method(self, bufsize, *args, **kwargs)
246-
except Exception as ex:
247-
if socketdata and socketdata.record:
248-
socketdata.record.exception = ex
249-
raise
239+
buffer = method(self, bufsize, *args, **kwargs)
250240

251241
if socketdata and socketdata.record:
252242
socketdata.record.receive_data(buffer)
@@ -298,12 +288,8 @@ def hook(self, data, *args, **kwargs):
298288
records.requests[socketdata.record.id] = socketdata.record
299289
elif http_detected is False: # if None, there is nothing to do
300290
records._sockets[id(self)] = None
301-
try:
302-
return method(self, data, *args, **kwargs)
303-
except Exception as ex:
304-
if socketdata and socketdata.record:
305-
socketdata.record.exception = ex
306-
raise
291+
292+
return method(self, data, *args, **kwargs)
307293

308294
return hook
309295

@@ -320,12 +306,7 @@ def hook(self, data, *args, **kwargs):
320306
f"SEND - self={self} id={id(self)} socketdata={socketdata} bytes={(b''+data)[:20]} args={args} kwargs={kwargs}"
321307
)
322308

323-
try:
324-
size = method(self, data, *args, **kwargs)
325-
except Exception as ex:
326-
if socketdata and socketdata.record:
327-
socketdata.record.exception = ex
328-
raise
309+
size = method(self, data, *args, **kwargs)
329310

330311
if socketdata:
331312
if socketdata.record:
@@ -399,12 +380,7 @@ def hook(self, buf, *args, **kwargs):
399380
if socketdata:
400381
logger().info(f"WRITE * - socketdata={socketdata}")
401382

402-
try:
403-
size = method(self, buf, *args, **kwargs)
404-
except Exception as ex:
405-
if socketdata and socketdata.record:
406-
socketdata.record.exception = ex
407-
raise
383+
size = method(self, buf, *args, **kwargs)
408384

409385
if socketdata:
410386
if socketdata.record:
@@ -446,13 +422,7 @@ def hook(self, *args, **kwargs):
446422
if socketdata:
447423
logger().info(f"READ * - socketdata={socketdata}")
448424

449-
try:
450-
r = method(self, *args, **kwargs)
451-
except Exception as ex:
452-
if not isinstance(ex, ssl.SSLWantReadError):
453-
if socketdata and socketdata.record:
454-
socketdata.record.exception = ex
455-
raise
425+
r = method(self, *args, **kwargs)
456426

457427
if socketdata and socketdata.record:
458428
allargs = getcallargs(method, self, *args, **kwargs)

0 commit comments

Comments
 (0)