[yt-svn] commit/yt: MatthewTurk: Raise an exception instead of returning None when load fails.

Bitbucket commits-noreply at bitbucket.org
Tue May 1 14:11:27 PDT 2012


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/78a16256d467/
changeset:   78a16256d467
branch:      yt
user:        MatthewTurk
date:        2012-05-01 21:03:29
summary:     Raise an exception instead of returning None when load fails.
affected #:  2 files

diff -r b48beb25efe03efaf578d6b968798e87548afef9 -r 78a16256d4679b6ad267352abed15f54f5c2d817 yt/convenience.py
--- a/yt/convenience.py
+++ b/yt/convenience.py
@@ -62,7 +62,7 @@
     if not any(valid_file):
         mylog.error("None of the arguments provided to load() is a valid file")
         mylog.error("Please check that you have used a correct path")
-        return None
+        raise YTOutputNotIdentified(args, kwargs)
     for n, c in output_type_registry.items():
         if n is None: continue
         if c._is_valid(*args, **kwargs): candidates.append(n)
@@ -83,7 +83,7 @@
     mylog.error("Multiple output type candidates for %s:", args[0])
     for c in candidates:
         mylog.error("    Possible: %s", c)
-    return None
+    raise YTOutputNotIdentified(args, kwargs)
 
 def projload(pf, axis, weight_field = None):
     # This is something of a hack, so that we can just get back a projection


diff -r b48beb25efe03efaf578d6b968798e87548afef9 -r 78a16256d4679b6ad267352abed15f54f5c2d817 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -33,6 +33,15 @@
 
 # Data access exceptions:
 
+class YTOutputNotIdentified(YTException):
+    def __init__(self, args, kwargs):
+        self.args = args
+        self.kwargs = kwargs
+
+    def __str__(self):
+        return "Supplied %s %s, but could not load!" % (
+            self.args, self.kwargs)
+
 class YTSphereTooSmall(YTException):
     def __init__(self, pf, radius, smallest_cell):
         YTException.__init__(self, pf)

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list