Fix serialization of text values in VC
Change-Id: Idcabb4d6c69020c6a9911669853bdafb8c934f21
diff --git a/dev/js/src/vc/doc.js b/dev/js/src/vc/doc.js
index d2a413e..15c7287 100644
--- a/dev/js/src/vc/doc.js
+++ b/dev/js/src/vc/doc.js
@@ -9,8 +9,14 @@
'util'
], function (jsonldClass, rewriteListClass, stringValClass) {
+ /*
+ * TODO:
+ * Improve error handling by using window.onerror() to
+ * capture thrown errors and log them.
+ */
const errstr802 = "Match type is not supported by value type";
+ const errstr804 = "Unknown value type";
const loc = KorAP.Locale;
loc.EMPTY = loc.EMPTY || '⋯';
@@ -319,8 +325,8 @@
}
else {
- KorAP.log(804, "Unknown value type");
- return;
+ KorAP.log(804, errstr804 + ": " + this.type());
+ throw new Error(errstr804 + ": " + this.type());
};
};
@@ -622,13 +628,11 @@
switch (this.type()) {
case "date":
return string + this.value();
- break;
case "regex":
return string + '/' + this.value().escapeRegex() + '/';
- break;
case "string":
+ case "text":
return string + '"' + this.value().quote() + '"';
- break;
};
return "";