diff options
author | Adam Chlipala <adam@chlipala.net> | 2015-11-01 12:23:44 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2015-11-01 12:23:44 -0500 |
commit | 7f6d55c4b44a7e17d17b721e0d5a967f3c5fa6aa (patch) | |
tree | ecfdb7a95770edea0c257496433da40eee9ad482 /lib | |
parent | 3cf49898acbf6701b04a1de4938241f1009c5e5a (diff) |
Better client-side error messages for RPC failures
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/urweb.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index ac4e4c9e..45ed6be8 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -472,8 +472,11 @@ function onConnectFail(f) { connectHandlers = cons(flift(f), connectHandlers); } -function conn() { - runHandlers("Connect", connectHandlers, null); +function conn(msg) { + var rx = /(.*)<body>((.|\n|\r)*)<\/body>(.*)/g; + var arr = rx.exec(msg); + msg = (arr && arr.length >= 3) ? arr[2] : msg; + runHandlers("RPC failure", connectHandlers, msg); } var serverHandlers = null; @@ -1595,7 +1598,7 @@ function rc(prefix, uri, parse, k, needsSig, isN) { } } else { if (isN == null) - conn(); + conn(xhr.responseText); else k(null); } |