Skip to content

Commit e565ad5

Browse files
committed
better errors through broker
1 parent f955d2b commit e565ad5

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

copyparty/broker_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get(self, block: bool = True, timeout: Optional[float] = None) -> Any:
2828
if rv[1] == "pebkac":
2929
raise Pebkac(*rv[2:])
3030
else:
31-
raise Exception(rv[2])
31+
raise rv[2]
3232

3333
return rv
3434

@@ -65,8 +65,8 @@ def try_exec(want_retval: Union[bool, int], func: Any, *args: list[Any]) -> Any:
6565

6666
return ["exception", "pebkac", ex.code, str(ex)]
6767

68-
except:
68+
except Exception as ex:
6969
if not want_retval:
7070
raise
7171

72-
return ["exception", "stack", traceback.format_exc()]
72+
return ["exception", "stack", ex]

copyparty/httpcli.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,8 @@ def run(self) -> bool:
646646
if not self._check_nonfatal(pex, post):
647647
self.keepalive = False
648648

649-
if pex is ex:
650-
em = msg = str(ex)
651-
else:
652-
em = repr(ex)
653-
msg = min_ex()
649+
em = str(ex)
650+
msg = em if pex is ex else min_ex()
654651

655652
if pex.code != 404 or self.do_log:
656653
self.log(

copyparty/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ def vol_san(vols: list["VFS"], txt: bytes) -> bytes:
13771377
def min_ex(max_lines: int = 8, reverse: bool = False) -> str:
13781378
et, ev, tb = sys.exc_info()
13791379
stb = traceback.extract_tb(tb) if tb else traceback.extract_stack()[:-1]
1380-
fmt = "%s @ %d <%s>: %s"
1380+
fmt = "%s:%d <%s>: %s"
13811381
ex = [fmt % (fp.split(os.sep)[-1], ln, fun, txt) for fp, ln, fun, txt in stb]
13821382
if et or ev or tb:
13831383
ex.append("[%s] %s" % (et.__name__ if et else "(anonymous)", ev))

0 commit comments

Comments
 (0)