]> git.parisson.com Git - pdf.js.git/commitdiff
Fix worker message, better error handling
authorArtur Adib <arturadib@gmail.com>
Thu, 19 Jan 2012 19:19:19 +0000 (14:19 -0500)
committerArtur Adib <arturadib@gmail.com>
Thu, 19 Jan 2012 19:19:19 +0000 (14:19 -0500)
src/evaluator.js
src/worker.js

index 21530f42fafb8d17d32183cc5d0a40e0f983efa2..1c277e0276fe9d1977e4735a07059069aaeef9f7 100644 (file)
@@ -159,6 +159,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
             // a Stream in the main thread.
             if (translated.file)
               translated.file = translated.file.getBytes();
+            if (translated.properties.file) {
+              translated.properties.file =
+                  translated.properties.file.getBytes();
+            }
 
             handler.send('obj', [
                 loadedName,
@@ -779,12 +783,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
             dict: baseDict,
             properties: properties
           };
-        }
-
-      }
+        } // if (type.name == 'Type3')
+      } // if (!descriptor)
 
       // According to the spec if 'FontDescriptor' is declared, 'FirstChar',
-      // 'LastChar' and 'Widths' should exists too, but some PDF encoders seems
+      // 'LastChar' and 'Widths' should exist too, but some PDF encoders seem
       // to ignore this rule when a variant of a standart font is used.
       // TODO Fill the width array depending on which of the base font this is
       // a variant.
index 4d9dd1bb637a96c68398ca0015689eae9a63df5a..468cce0193b85fdb2c7d670c7b26d0e62341ceb4 100644 (file)
@@ -109,11 +109,27 @@ var WorkerMessageHandler = {
         // Pre compile the pdf page and fetch the fonts/images.
         IRQueue = page.getIRQueue(handler, dependency);
       } catch (e) {
+        var minimumStackMessage =
+            'worker.js: while trying to getPage() and getIRQueue()';
+
         // Turn the error into an obj that can be serialized
-        e = {
-          message: typeof e === 'object' ? e.message : e,
-          stack: typeof e === 'object' ? e.stack : null
-        };
+        if (typeof e === 'string') {
+          e = {
+            message: e,
+            stack: minimumStackMessage
+          };
+        } else if (typeof e === 'object') {
+          e = {
+            message: e.message || e.toString(),
+            stack: e.stack || minimumStackMessage
+          };
+        } else {
+          e = {
+            message: 'Unknown exception type: ' + (typeof e),
+            stack: minimumStackMessage
+          }
+        }
+
         handler.send('page_error', {
           pageNum: pageNum,
           error: e