summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-08-28 20:06:48 +0100
committerMichael Williamson <mike@zwobble.org>2016-08-28 20:06:48 +0100
commit174dc90dc6e13cc3e5a3a89d08f7e651541a9056 (patch)
tree09b6306b7f7e705bf66816201d8763cfce129a54
parentd333cee1c7a7f95cadf5b59e8dbb0124d73852df (diff)
Include error on the error message, rather than just the stack
-rw-r--r--README.md5
-rw-r--r--lib/results.js2
-rw-r--r--test/document-to-html.tests.js1
3 files changed, 6 insertions, 2 deletions
diff --git a/README.md b/README.md
index 4f310a0..ccbd35f 100644
--- a/README.md
+++ b/README.md
@@ -437,10 +437,13 @@ mammoth.embedStyleMap({path: sourcePath}, "p[style-name='Section Title'] => h1:f
Each message has the following properties:
-* `type`: a string representing the type of the message, such as `"warning"`
+* `type`: a string representing the type of the message, such as `"warning"` or
+ `"error"`
* `message`: a string containing the actual message
+* `error` (optional): the thrown exception that caused this message, if any
+
#### Image converters
An image converter can be created by calling `mammoth.images.imgElement(func)`.
diff --git a/lib/results.js b/lib/results.js
index 043f1f9..7d3ca69 100644
--- a/lib/results.js
+++ b/lib/results.js
@@ -49,7 +49,7 @@ function error(exception) {
return {
type: "error",
message: exception.message,
- stack: exception.stack
+ error: exception
};
}
diff --git a/test/document-to-html.tests.js b/test/document-to-html.tests.js
index 59eba49..6283b1a 100644
--- a/test/document-to-html.tests.js
+++ b/test/document-to-html.tests.js
@@ -609,6 +609,7 @@ test('when custom image handler throws error then error is stored in error messa
var message = result.messages[0];
assert.equal("error", message.type);
assert.equal("Failed to convert image", message.message);
+ assert.equal(error, message.error);
});
});