Physikerwelt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/284700

Change subject: Improve debug output
......................................................................

Improve debug output

Change-Id: I28b905f6af5f4e7942f734926f3419ed1ea68dc5
---
M routes/mathoid.js
1 file changed, 65 insertions(+), 56 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mathoid 
refs/changes/00/284700/1

diff --git a/routes/mathoid.js b/routes/mathoid.js
index d5a5e12..3393366 100644
--- a/routes/mathoid.js
+++ b/routes/mathoid.js
@@ -93,65 +93,74 @@
         }
     }
 
-    app.mjAPI.typeset({
-        math: q,
-        format: type,
-        svg: svg,
-        mathoidStyle: img,
-        mml: mml,
-        speakText: speech,
-        png: png
-    }, function (data) {
-        if (data.errors) {
-            data.success = false;
-            // @deprecated replace with emitError
-            data.log = "Error:" + JSON.stringify(data.errors);
-        } else {
-            data.success = true;
-            // @deprecated
-            data.log = "success";
-        }
-
-        // Return the sanitized TeX to the client
-        if (sanitizedTex !== undefined) {
-            data.sanetex = sanitizedTex;
-        }
-        if (speech) {
-            data.speech = data.speakText;
-        }
-
-        function outputResponse() {
-            switch (outFormat) {
-                case 'json':
-                    res.json(data).end();
-                    break;
-                case 'complete':
-                    var headers = outHeaders(data);
-                    Object.keys(headers).forEach(function (outType) {
-                        if (data[outType]) {
-                            data[outType] = {
-                                headers: headers[outType],
-                                body: data[outType]
-                            };
-                        }
-                    });
-                    res.json(data).end();
-                    break;
-                default:
-                    res.set(outHeaders(data)[outFormat]);
-                    res.send(data[outFormat]).end();
+    try {
+        app.mjAPI.typeset({
+            math: q,
+            format: type,
+            svg: svg,
+            mathoidStyle: img,
+            mml: mml,
+            speakText: speech,
+            png: png
+        }, function (data) {
+            if (data.errors) {
+                data.success = false;
+                // @deprecated replace with emitError
+                data.log = "Error:" + JSON.stringify(data.errors);
+            } else {
+                data.success = true;
+                // @deprecated
+                data.log = "success";
             }
-        }
 
-        if (data.svg) {
-            svgo.optimize( data.svg, function ( result ) {
-                data.svg = result.data;
+            // Return the sanitized TeX to the client
+            if (sanitizedTex !== undefined) {
+                data.sanetex = sanitizedTex;
+            }
+            if (speech) {
+                data.speech = data.speakText;
+            }
+
+            function outputResponse() {
+                switch (outFormat) {
+                    case 'json':
+                        res.json(data).end();
+                        break;
+                    case 'complete':
+                        var headers = outHeaders(data);
+                        Object.keys(headers).forEach(function (outType) {
+                            if (data[outType]) {
+                                data[outType] = {
+                                    headers: headers[outType],
+                                    body: data[outType]
+                                };
+                            }
+                        });
+                        res.json(data).end();
+                        break;
+                    default:
+                        res.set(outHeaders(data)[outFormat]);
+                        res.send(data[outFormat]).end();
+                }
+            }
+
+            if (data.svg) {
+                svgo.optimize(data.svg, function (result) {
+                    data.svg = result.data;
+                    outputResponse();
+                });
+            } else {
                 outputResponse();
-            } );
-        } else {
-            outputResponse();
-        }
-    });
+            }
+        });
+    } catch (e) {
+        app.logger.log('error', 'MathJax bug while processing details:' + 
JSON.stringify({
+                q: q,
+                type: type,
+                outFormat: outFormat,
+                error: e
+            }));
+    }
 }
 
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I28b905f6af5f4e7942f734926f3419ed1ea68dc5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mathoid
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>

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

Reply via email to