Skip to content

Commit

Permalink
Merge pull request #116 from macisamuele/maci-pre-commit-erros-provid…
Browse files Browse the repository at this point in the history
…e-underlying-tool-message

Expose underlying tools error messages while tracking failure of pre-commit hook
  • Loading branch information
macisamuele authored Jul 1, 2022
2 parents 09e789a + bd2aa57 commit f5d39cc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion language_formatters_pre_commit_hooks/pretty_format_ini.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def pretty_format_ini(argv: typing.Optional[typing.List[str]] = None) -> int:
output_file.write(pretty_content_str)

status = 1
except Exception as e:
except BaseException as e:
print("Input File {} is not a valid INI file: {}".format(ini_file, e))
return 1

Expand Down
5 changes: 2 additions & 3 deletions language_formatters_pre_commit_hooks/pretty_format_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import typing

from toml_sort import TomlSort
from tomlkit.exceptions import ParseError

from language_formatters_pre_commit_hooks.utils import remove_trailing_whitespaces_and_set_new_line_ending

Expand Down Expand Up @@ -40,8 +39,8 @@ def pretty_format_toml(argv: typing.Optional[typing.List[str]] = None) -> int:
output_file.write(prettified_content)

status = 1
except ParseError:
print("Input File {} is not a valid TOML file".format(toml_file))
except BaseException as e:
print("Input File {} is not a valid TOML file: {}".format(toml_file, e))
return 1

return status
Expand Down
7 changes: 2 additions & 5 deletions language_formatters_pre_commit_hooks/pretty_format_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from sys import maxsize

from ruamel.yaml import YAML
from ruamel.yaml.error import YAMLError


def _process_single_document(document: str, yaml: YAML) -> str:
Expand Down Expand Up @@ -113,11 +112,9 @@ def pretty_format_yaml(argv: typing.Optional[typing.List[str]] = None) -> int:
output_file.write(str(pretty_content))

status = 1
except YAMLError: # pragma: no cover
except BaseException as e: # pragma: no cover
print(
"Input File {} is not a valid YAML file, consider using check-yaml".format(
yaml_file,
),
"Input File {} is not a valid YAML file, consider using check-yaml: {}".format(yaml_file, e),
)
return 1

Expand Down

0 comments on commit f5d39cc

Please sign in to comment.