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
parent
fb52e7a5c8
commit
d753e56a2a
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue