# HG changeset patch # User Adam Chlipala # Date 1446398624 18000 # Node ID 61866c765485800fb0ed2446f181e84501e6fd05 # Parent 14c45a0b63628fc55b04f72d07d7e48784905d0a Better client-side error messages for RPC failures diff -r 14c45a0b6362 -r 61866c765485 lib/js/urweb.js --- a/lib/js/urweb.js Sun Nov 01 11:55:01 2015 -0500 +++ b/lib/js/urweb.js Sun Nov 01 12:23:44 2015 -0500 @@ -472,8 +472,11 @@ connectHandlers = cons(flift(f), connectHandlers); } -function conn() { - runHandlers("Connect", connectHandlers, null); +function conn(msg) { + var rx = /(.*)((.|\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 @@ } } else { if (isN == null) - conn(); + conn(xhr.responseText); else k(null); }