From 6fd55e8d2e0fc03914402bf6c8fe7cded9e1e042 2012-05-28 21:20:14 From: Thomas Kluyver Date: 2012-05-28 21:20:14 Subject: [PATCH] Tidy up error raising in magic decorators. 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