mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-04 07:18:27 +01:00
dvc: show "Having any troubles?" only on unexpected errors (#4496)
* dvc: dont catch generic exceptions * dvc: show "Having any troubles?" only on unexpected errors Fixes #4126
This commit is contained in:
@@ -25,7 +25,7 @@ class CmdDestroy(CmdBase):
|
||||
)
|
||||
|
||||
self.repo.destroy()
|
||||
except Exception: # noqa, pylint: disable=broad-except
|
||||
except DvcException:
|
||||
logger.exception("failed to destroy DVC")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
@@ -2,6 +2,7 @@ import argparse
|
||||
import logging
|
||||
|
||||
from dvc.command.base import CmdBase, append_doc_link
|
||||
from dvc.exceptions import DvcException
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -10,7 +11,7 @@ class CmdInstall(CmdBase):
|
||||
def run(self):
|
||||
try:
|
||||
self.repo.install(self.args.use_pre_commit_tool)
|
||||
except Exception: # noqa, pylint:disable=broad-except
|
||||
except DvcException:
|
||||
logger.exception("failed to install DVC Git hooks")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
|
||||
from dvc.command.data_sync import CmdDataBase
|
||||
from dvc.exceptions import DvcException
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -63,7 +64,7 @@ class CmdDataStatus(CmdDataBase):
|
||||
else:
|
||||
logger.info(self.UP_TO_DATE_MSG)
|
||||
|
||||
except Exception: # noqa, pylint: disable=broad-except
|
||||
except DvcException:
|
||||
logger.exception("failed to obtain data status")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
+4
-10
@@ -87,8 +87,9 @@ def main(argv=None): # noqa: C901
|
||||
except DvcException:
|
||||
ret = 255
|
||||
logger.exception("")
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.EMFILE:
|
||||
except Exception as exc: # noqa, pylint: disable=broad-except
|
||||
# pylint: disable=no-member
|
||||
if isinstance(exc, OSError) and exc.errno == errno.EMFILE:
|
||||
logger.exception(
|
||||
"too many open files, please visit "
|
||||
"{} to see how to handle this "
|
||||
@@ -97,17 +98,10 @@ def main(argv=None): # noqa: C901
|
||||
)
|
||||
else:
|
||||
logger.exception("unexpected error")
|
||||
ret = 255
|
||||
except Exception: # noqa, pylint: disable=broad-except
|
||||
logger.exception("unexpected error")
|
||||
logger.info(FOOTER)
|
||||
ret = 255
|
||||
|
||||
try:
|
||||
if ret != 0 and (
|
||||
ret != 1 or getattr(args, "cmd", "") != "check-ignore"
|
||||
):
|
||||
logger.info(FOOTER)
|
||||
|
||||
if analytics.is_enabled():
|
||||
analytics.collect_and_send_report(args, ret)
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ def test_check_ignore_non_matching(tmp_dir, dvc, non_matching, caplog):
|
||||
)
|
||||
def test_check_ignore_error_args_cases(tmp_dir, dvc, args, caplog):
|
||||
assert main(["check-ignore"] + args) == 255
|
||||
assert ("Having any troubles?" in caplog.text) == ("-q" not in args)
|
||||
assert "Having any troubles?" not in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path,ret", [({"dir": {}}, 0), ({"dir": "files"}, 1)])
|
||||
|
||||
Reference in New Issue
Block a user