Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow TryNext to have an error message without it affecting the comma…

…nd chain.

Closes gh-211
  • Loading branch information...
commit cdd3c8509b8d147f9f13b728abfbed0d5cd9b4d6 1 parent 2b6643e
@takluyver authored
Showing with 10 additions and 3 deletions.
  1. +8 −1 IPython/core/error.py
  2. +2 −2 IPython/lib/clipboard.py
View
9 IPython/core/error.py
@@ -38,11 +38,18 @@ class TryNext(IPythonCoreError):
should be used to handle the operation. If you pass arguments to the
constructor those arguments will be used by the next hook instead of the
original ones.
+
+ A _msg argument will not be passed on, so it can be used as a displayable
+ error message.
"""
- def __init__(self, *args, **kwargs):
+ def __init__(self, _msg="", *args, **kwargs):
self.args = args
self.kwargs = kwargs
+ self.msg = _msg
+
+ def __str__(self):
+ return str(self.msg)
class UsageError(IPythonCoreError):
"""Error in magic function arguments, etc.
View
4 IPython/lib/clipboard.py
@@ -17,7 +17,7 @@ def win32_clipboard_get():
except ImportError:
message = ("Getting text from the clipboard requires the pywin32 "
"extensions: http://sourceforge.net/projects/pywin32/")
- raise TryNext(message)
+ raise TryNext(_msg=message)
win32clipboard.OpenClipboard()
text = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT)
# FIXME: convert \r\n to \n?
@@ -46,7 +46,7 @@ def tkinter_clipboard_get():
except ImportError:
message = ("Getting text from the clipboard on this platform "
"requires Tkinter.")
- raise TryNext(message)
+ raise TryNext(_msg=message)
root = Tkinter.Tk()
root.withdraw()
text = root.clipboard_get()
Please sign in to comment.
Something went wrong with that request. Please try again.