diff --git a/index.js b/index.js
index ce335e3640547327bf041e2a629d3b86e4059234..3bf81ab6995d36dbb846d419fe3468fdc738c183 100644
--- a/index.js
+++ b/index.js
@@ -174,7 +174,7 @@ module.exports = function math_plugin(md, options) {
         }
         catch(error){
             if(options.throwOnError){ console.log(error); }
-            return `<span class='katex-error' title='${escapeHtml(error)}'>${escapeHtml(latex)}</span>`;
+            return `<span class='katex-error' title='${escapeHtml(error.toString())}'>${escapeHtml(latex)}</span>`;
         }
     };
 
@@ -189,7 +189,7 @@ module.exports = function math_plugin(md, options) {
         }
         catch(error){
             if(options.throwOnError){ console.log(error); }
-            return `<p class='katex-block katex-error' title='${escapeHtml(error)}'>${escapeHtml(latex)}</p>`;
+            return `<p class='katex-block katex-error' title='${escapeHtml(error.toString())}'>${escapeHtml(latex)}</p>`;
         }
     }