summaryrefslogtreecommitdiff
path: root/lib/js/urweb.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r--lib/js/urweb.js41
1 files changed, 30 insertions, 11 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index cc65ab8f..f56ba4c6 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -1365,7 +1365,14 @@ function redirect(s) {
window.location = s;
}
-function rc(prefix, uri, parse, k, needsSig) {
+function makeSome(isN, v) {
+ if (isN)
+ return {v: v};
+ else
+ return v;
+}
+
+function rc(prefix, uri, parse, k, needsSig, isN) {
if (!maySuspend)
er("May not 'rpc' in main thread of 'code' for <active>");
@@ -1384,18 +1391,30 @@ function rc(prefix, uri, parse, k, needsSig) {
if (isok) {
var lines = xhr.responseText.split("\n");
- if (lines.length != 2)
- whine("Bad RPC response lines");
-
- eval(lines[0]);
-
- try {
- k(parse(lines[1]));
- } catch (v) {
- doExn(v);
+ if (lines.length != 2) {
+ if (isN == null)
+ whine("Bad RPC response lines");
+ else
+ k(null);
+ } else {
+ eval(lines[0]);
+
+ try {
+ var v = parse(lines[1]);
+ try {
+ k(makeSome(isN, v));
+ } catch (v) {
+ doExn(v);
+ }
+ } catch (v) {
+ k(null);
+ }
}
} else {
- conn();
+ if (isN == null)
+ conn();
+ else
+ k(null);
}
xhrFinished(xhr);