From 740fbd216844b2bae4b0f6c3763d7b41fbe68e5b Mon Sep 17 00:00:00 2001 From: Amir MOHAMMADI <amir.mohammadi@idiap.ch> Date: Mon, 9 May 2022 19:12:16 +0200 Subject: [PATCH] improve error messages --- bob/io/base/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bob/io/base/__init__.py b/bob/io/base/__init__.py index cced69b..7152f6c 100644 --- a/bob/io/base/__init__.py +++ b/bob/io/base/__init__.py @@ -193,19 +193,19 @@ def load(inputs): if _is_string(inputs): if not os.path.exists(inputs): raise RuntimeError(f"`{inputs}' does not exist!") - return open_file(inputs) + try: + return open_file(inputs) + except Exception as e: + raise RuntimeError(f"Could not load `{inputs}'!") from e elif isinstance(inputs, Iterable): retval = [] for obj in inputs: if _is_string(obj): retval.append(load(obj)) - # elif isinstance(obj, File): - # retval.append(obj.read()) else: raise TypeError( - "Iterable contains an object which is not a filename nor a " - "bob.io.base.File." + "Iterable contains an object which is not a filename" ) return numpy.vstack(retval) else: -- GitLab