Permalink
Browse files

Tidy up error raising in magic decorators.

Closes gh-1778
  • Loading branch information...
1 parent 89c2337 commit 6fd55e8d2e0fc03914402bf6c8fe7cded9e1e042 @takluyver committed May 28, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 IPython/core/magic.py
View
@@ -203,8 +203,8 @@ def mark(func, *a, **kw):
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 magic_deco(arg):
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 mark(func, *a, **kw):
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

0 comments on commit 6fd55e8

Please sign in to comment.