Skip to content

Commit 5243afe

Browse files
committed
[feature] Improve debug output for method calls
1 parent 5736b0e commit 5243afe

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

mfusepy.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# to 0 and the ctypes module does that for us out of the box!
1818
# https://github.com/python/cpython/blob/f8a736b8e14ab839e1193cb1d3955b61c316d048/Lib/test/test_ctypes/test_numbers.py#L95
1919

20+
import contextlib
2021
import ctypes
2122
import errno
2223
import functools
@@ -1258,12 +1259,22 @@ def _wrapper(self, func, *args, **kwargs):
12581259
if func.__name__ == "init":
12591260
raise e
12601261
if isinstance(e.errno, int) and e.errno > 0:
1262+
is_valid_exception = (func.__name__.startswith("getattr") and e.errno == errno.ENOENT) or (
1263+
func.__name__ == "getxattr" and e.errno == errno.ENODATA
1264+
)
1265+
1266+
error_string = ""
1267+
with contextlib.suppress(ValueError):
1268+
error_string = os.strerror(e.errno)
1269+
12611270
log.debug(
1262-
"FUSE operation %s raised a %s, returning errno %s.",
1271+
"FUSE operation %s (%s) raised a %s, returning errno %s (%s).",
12631272
func.__name__,
1273+
args,
12641274
type(e),
12651275
e.errno,
1266-
exc_info=True,
1276+
error_string,
1277+
exc_info=not is_valid_exception,
12671278
)
12681279
return -e.errno
12691280
log.exception(

0 commit comments

Comments
 (0)