jenkins-bot has submitted this change and it was merged.

Change subject: Fix some does not exist errors
......................................................................


Fix some does not exist errors

 * Surfaced in bug 63613.

Change-Id: I691c171c1e3290e06bdeaa32abc818560ba2b135
---
M api/ParsoidService.js
M lib/LogData.js
M lib/mediawiki.ApiRequest.js
3 files changed, 20 insertions(+), 11 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  Marcoil: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/api/ParsoidService.js b/api/ParsoidService.js
index 9963002..11d9db5 100644
--- a/api/ParsoidService.js
+++ b/api/ParsoidService.js
@@ -19,7 +19,8 @@
        path = require('path'),
        util = require('util'),
        pkg = require('../package.json'),
-       Diff = require('../lib/mediawiki.Diff.js').Diff;
+       Diff = require('../lib/mediawiki.Diff.js').Diff,
+       LogData = require('../lib/LogData.js').LogData;
 
 // local includes
 var mp = '../lib/';
@@ -343,22 +344,24 @@
 
                        function errCB ( res, env, logData, callback ) {
                                try {
-                                       if (env.responseSent) {
-                                               callback();
-                                               return;
-                                       } else {
+                                       if ( !env.responseSent ) {
                                                setHeader(res, env, 
'Content-Type', 'text/plain; charset=UTF-8' );
                                                sendResponse(res, env, 
logData.fullMsg(), logData.code || 500);
-                                               res.on('finish', callback);
+                                               if ( typeof callback === 
'function' ) {
+                                                       res.on('finish', 
callback);
+                                               }
+                                               return;
                                        }
                                } catch (e) {
+                                       console.log( e.stack );
+                               }
+                               if ( typeof callback === 'function' ) {
                                        callback();
-                                       return;
                                }
                        }
 
                        if ( err ) {
-                               return errCB(res, null, err);
+                               return errCB(res, {}, new LogData(null, 
"error", err));
                        }
 
                        env.logger.registerBackend(/fatal(\/.*)?/, 
errCB.bind(this, res, env));
diff --git a/lib/LogData.js b/lib/LogData.js
index 916fe15..8baf892 100644
--- a/lib/LogData.js
+++ b/lib/LogData.js
@@ -130,6 +130,9 @@
  * @param {String} topLevel
  */
 LogData.prototype._announceLocation = function () {
+       if ( !this._env ) {
+               return "";
+       }
        var location = this.logType + ' in ' + this._env.conf.wiki.iwp + ':' + 
this._env.page.name;
        if (this._env.page.revision && this._env.page.revision.revid) {
                location += ' with oldid: ' + this._env.page.revision.revid;
diff --git a/lib/mediawiki.ApiRequest.js b/lib/mediawiki.ApiRequest.js
index dd96bbe..9f1edce 100644
--- a/lib/mediawiki.ApiRequest.js
+++ b/lib/mediawiki.ApiRequest.js
@@ -29,6 +29,7 @@
  * @extends Error
  */
 function DoesNotExistError( message ) {
+    Error.captureStackTrace(this, DoesNotExistError);
     this.name = "DoesNotExistError";
     this.message = message || "Something doesn't exist";
     this.code = 404;
@@ -40,6 +41,7 @@
  * @extends Error
  */
 function ParserError( message ) {
+    Error.captureStackTrace(this, ParserError);
     this.name = "ParserError";
     this.message = message || "Generic parser error";
     this.code = 500;
@@ -51,6 +53,7 @@
  * @extends Error
  */
 function AccessDeniedError( message ) {
+    Error.captureStackTrace(this, AccessDeniedError);
        this.name = 'AccessDeniedError';
        this.message = message || 'Your wiki requires a logged-in account to 
access the API.';
        this.code = 401;
@@ -77,6 +80,7 @@
        this.retries = 8;
        this.env = env;
        this.title = title;
+       this.queueKey = title;
        this.reqType = "Page Fetch";
 }
 
@@ -135,7 +139,6 @@
  * @param {string} body The body of the response from the API
  */
 ApiRequest.prototype._requestCB = function (error, response, body) {
-       //console.warn( 'response for ' + title + ' :' + body + ':' );
        var self = this;
 
        if (error) {
@@ -148,8 +151,7 @@
                        return;
                } else {
                        var dnee = new DoesNotExistError( this.reqType + ' 
failure for '
-                                       + 
JSON.stringify(this.queueKey.substr(0, 20)) + ': ' + error );
-                       //this.emit('src', dnee, dnee.toString(), 
'text/x-mediawiki');
+                                       + 
JSON.stringify(this.queueKey.substr(0, 80)) + ': ' + error );
                        this._handleBody( dnee, '{}' );
                }
        } else if (response.statusCode === 200) {
@@ -638,6 +640,7 @@
  */
 var ConfigRequest = function ( apiURI, env, apiProxyURI ) {
        ApiRequest.call( this, env, null );
+       this.queueKey = apiURI;
 
        var metas = [
                        'siteinfo'

-- 
To view, visit https://gerrit.wikimedia.org/r/124375
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I691c171c1e3290e06bdeaa32abc818560ba2b135
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Marcoil <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to