Coverage for bugscpp/errors/common/exception.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Base exception class for defects4cpp.
4All user-defined exceptions should inherit from this class.
5"""
6from os import stat
7from stat import filemode
10class DppError(Exception):
11 @staticmethod
12 def print_path(path: str) -> str:
13 """
14 Path with its file stat.
16 Parameters
17 ----------
18 path : str
19 Path to file
21 Returns
22 -------
23 str
24 Return string of path with its stat information.
25 """
26 try:
27 return f"{filemode(stat(path).st_mode)} {path}"
28 except FileNotFoundError:
29 return f"(nonexistent) {path}"