"""
This module implements the some simple utilitiy functions.

..  :copyright: (c) 2016 by Jelte Fennema.
    :license: MIT, see License for more details.
"""

from llfuse import FUSEError

from contextlib import contextmanager
import errno
import logging


@contextmanager
def _convert_error_to_fuse_error(action, thing):
    try:
        yield
    except Exception as e:
        if isinstance(e, FUSEError):
            raise e
        logging.error('Something went wrong when %s %s: %s', action, thing, e)
        raise FUSEError(errno.EAGAIN)

@@ -250,16 +250,33 @@
 logging%0A
+import traceback%0A
 %0A%0A@conte
@@ -520,16 +520,156 @@
 ing, e)%0A
+        if logging.getLogger().isEnabledFor(logging.DEBUG):%0A            # DEBUG logging, print stacktrace%0A            traceback.print_exc()%0A
         

Print traceback on captured errors when loglevel is DEBUG