+var errorHandler = function( $link ) {
+
+ // Reset link text to whatever it was before we switching it to the '(un)watch'+ing message.
+ setLinkText( $link, $link.data( 'action' ) );
+
+ // Format error message
+ var cleanTitle = mw.config.get( 'wgPageName' ).replace( /_/g, ' ' );
+ var link = mw.html.element(
+ 'a', {
+ 'href': mw.util.wikiGetlink( mw.config.get( 'wgPageName' ) ),
+ 'title': cleanTitle
+ }, cleanTitle
+ );
+ var msg = mw.msg( 'watcherrortext', link );
+
+ // Report to user about the error
+ mw.util.jsMessage( msg, 'watch' );
+};
+
+/**
+ * Process the result of the API watch action.
+ *
+ * @param response Data object from API request.
+ * @param $link jQuery object of the watch link.
+ * @return Boolean true on success, false otherwise.
+ */