Provide more information when raising exception

This commit is contained in:
KV 2024-07-04 18:41:59 +02:00 committed by Daniel Rojas
parent ff6afac510
commit 38ca3e2689

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import platform
import sys import sys
from errno import EINVAL, ENAMETOOLONG from errno import EINVAL, ENAMETOOLONG
from pathlib import Path from pathlib import Path
@ -428,6 +429,9 @@ def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> Tuple[Dict, Path]:
# Catch these specific errors, but raise any others. # Catch these specific errors, but raise any others.
if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG, None): if type(e) is OSError and e.errno not in (EINVAL, ENAMETOOLONG, None):
print(
f"OSError(errno={e.errno}) in Python {sys.version} at {platform.platform()}"
)
raise e raise e
# file does not exist; assume inp is a YAML string # file does not exist; assume inp is a YAML string
yaml_str = inp yaml_str = inp