Skip to content

Commit

Permalink
refactor: Improve logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 14, 2022
1 parent 4ee8968 commit b8eb16e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/griffe/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,14 @@ def _load_submodule(self, module: Module, subparts: NamePartsType, subpath: Path
member_parent[subparts[-1]] = self._load_module_path(
subparts[-1], subpath, submodules=False, parent=member_parent
)
except SyntaxError:
message = traceback.format_exc(limit=0).replace("SyntaxError: invalid syntax", "").strip()
logger.error(f"Syntax error: {message}")
except SyntaxError as error: # noqa: WPS440
logger.debug(f"Syntax error: {error}")
except ImportError as error: # noqa: WPS440
logger.error(f"Import error: {error}")
logger.debug(f"Import error: {error}")
except UnicodeDecodeError as error: # noqa: WPS440
logger.error(f"UnicodeDecodeError when loading {subpath}: {error}")
logger.debug(f"UnicodeDecodeError when loading {subpath}: {error}")
except OSError as error: # noqa: WPS440
logger.error(f"OSError when loading {subpath}: {error}")
logger.debug(f"OSError when loading {subpath}: {error}")

def _create_module(self, module_name: str, module_path: Path) -> Module:
return Module(
Expand Down

0 comments on commit b8eb16e

Please sign in to comment.