From 5e21b9ee45cf3ed5911dcb220164f472d3b049ba 2012-05-28 21:42:05 From: Fernando Perez Date: 2012-05-28 21:42:05 Subject: [PATCH] Merge pull request #1779 from takluyver/i1778 Tidy up error raising in magic decorators, change a few exceptions for more appropriate kinds in new magics code. Closes gh-1778. --- diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 803b343..6d1c9d1 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -203,8 +203,8 @@ def _method_magic_marker(magic_kind): return decorator(call, func) retval = mark else: - raise ValueError("Decorator can only be called with " - "string or function") + raise TypeError("Decorator can only be called with " + "string or function") return retval # Ensure the resulting decorator has a usable docstring @@ -229,7 +229,8 @@ def _function_magic_marker(magic_kind): if get_ipython is not None: break else: - raise('Decorator can only run in context where `get_ipython` exists') + raise NameError('Decorator can only run in context where ' + '`get_ipython` exists') ip = get_ipython() @@ -247,7 +248,7 @@ def _function_magic_marker(magic_kind): return decorator(call, func) retval = mark else: - raise ValueError("Decorator can only be called with " + raise TypeError("Decorator can only be called with " "string or function") return retval