Skip to content

refactor: more informative error message when an unexpected error occurred. #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
UTIL_VERSION := 0.5.13
UTIL_VERSION := 0.5.14
UTIL_NAME := codeplag
PWD := $(shell pwd)

Expand Down
9 changes: 6 additions & 3 deletions src/codeplag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ def main() -> ExitCode:
except KeyboardInterrupt:
logger.warning("The util stopped by keyboard interrupt.")
return ExitCode.EXIT_KEYBOARD
except Exception:
except Exception as error:
logger.error(
"An unexpected error occurred while running the utility. "
"An unexpected error occurred while running the utility - %s. "
"For getting more information, check file '%s'.",
error,
LOG_PATH,
)
logger.debug("Trace:", exc_info=True)
stdout_handler = logger.handlers.pop()
logger.error("Trace:", exc_info=True)
logger.handlers.append(stdout_handler)
return ExitCode.EXIT_UNKNOWN

return code
4 changes: 3 additions & 1 deletion src/codeplag/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from codeplag.consts import (
DEFAULT_MODE,
UTIL_NAME,
UTIL_VERSION,
)
from codeplag.handlers.check import IgnoreThresholdWorksComparator, WorksComparator
from codeplag.handlers.report import (
Expand Down Expand Up @@ -55,7 +57,7 @@ def __init__(self: Self, parsed_args: dict[str, Any]) -> None:
self.directories: list[Path] = parsed_args.pop("directories", [])

def run(self: Self) -> ExitCode:
logger.debug("Starting codeplag util ...")
logger.info("Starting %s util (%s) ...", UTIL_NAME, UTIL_VERSION)

if self.root == "settings":
if self.command == "show":
Expand Down
Loading