diff --git a/IPython/core/error.py b/IPython/core/error.py index a7d20ca..cf7d546 100644 --- a/IPython/core/error.py +++ b/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. diff --git a/IPython/lib/clipboard.py b/IPython/lib/clipboard.py index cc6fb2a..30974b3 100644 --- a/IPython/lib/clipboard.py +++ b/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()