From d753e56a2aba1e58cb44513b632ebd0e2c343839 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 24 Jan 2017 10:53:54 -0800 Subject: [PATCH] Better error message for assertDoc (#449) Right now it says that the boolean expression fails which is not super useful. Instead, now it prints the actual value. --- src/doc-builders.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/doc-builders.js b/src/doc-builders.js index 7a0c1010..4e230cde 100644 --- a/src/doc-builders.js +++ b/src/doc-builders.js @@ -1,13 +1,11 @@ "use strict"; -const assert = require("assert"); const utils = require("./doc-utils"); const willBreak = utils.willBreak; function assertDoc(val) { - assert( - typeof val === "string" || val != null && typeof val.type === "string", - "Value is a valid document" - ); + if (!(typeof val === "string" || val != null && typeof val.type === "string")) { + throw new Error("Value " + JSON.stringify(val) + " is not a valid document"); + } } function concat(parts) {