MCPcopy
hub / github.com/treeverse/dvc / _log_exceptions

Function _log_exceptions

dvc/cli/__init__.py:57–148  ·  view source on GitHub ↗

Try to log some known exceptions, that are not DVCExceptions.

(exc: Exception)

Source from the content-addressed store, hash-verified

55
56
57def _log_exceptions(exc: Exception) -> Optional[int]:
58 """Try to log some known exceptions, that are not DVCExceptions."""
59 from dvc.utils import error_link, format_link
60
61 if isinstance(exc, OSError):
62 import errno
63
64 if exc.errno == errno.EMFILE:
65 logger.exception(
66 (
67 "too many open files, please visit "
68 "%s to see how to handle this problem"
69 ),
70 error_link("many-files"),
71 extra={"tb_only": True},
72 )
73 else:
74 _log_unknown_exceptions()
75 return None
76
77 from dvc.fs import AuthError, ConfigError, RemoteMissingDepsError
78
79 if isinstance(exc, RemoteMissingDepsError):
80 from dvc import PKG
81
82 proto = exc.protocol
83 by_pkg = {
84 "pip": f"pip install 'dvc[{proto}]'",
85 "conda": f"conda install -c conda-forge dvc-{proto}",
86 }
87
88 if PKG in by_pkg:
89 link = format_link("https://dvc.org/doc/install")
90 cmd = by_pkg.get(PKG)
91 hint = (
92 "To install dvc with those dependencies, run:\n"
93 "\n"
94 f"\t{cmd}\n"
95 "\n"
96 f"See {link} for more info."
97 )
98 else:
99 link = format_link("https://github.com/treeverse/dvc/issues")
100 hint = f"\nPlease report this bug to {link}. Thank you!"
101
102 logger.exception(
103 "URL '%s' is supported but requires these missing dependencies: %s. %s",
104 exc.url,
105 exc.missing_deps,
106 hint,
107 extra={"tb_only": True},
108 )
109 return None
110
111 if isinstance(exc, (AuthError, ConfigError)):
112 link = format_link("https://man.dvc.org/remote/modify")
113 logger.exception("configuration error")
114 logger.exception(

Callers 1

mainFunction · 0.85

Calls 5

error_linkFunction · 0.90
format_linkFunction · 0.90
relpathFunction · 0.90
_log_unknown_exceptionsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected