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.
master
Christopher Chedeau 2017-01-24 10:53:54 -08:00 committed by James Long
parent fb52e7a5c8
commit d753e56a2a
1 changed files with 3 additions and 5 deletions

View File

@ -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) {