Mercurial > urweb
comparison lib/js/urweb.js @ 1890:abb0e95dcaa1
Fix more of client-side error handlers
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 14 Nov 2013 06:36:36 -0500 |
parents | c40ed80be943 |
children | b6aee1d5b9b1 |
comparison
equal
deleted
inserted
replaced
1889:c40ed80be943 | 1890:abb0e95dcaa1 |
---|---|
374 if (!lameDuck) { | 374 if (!lameDuck) { |
375 if (ls == null) | 375 if (ls == null) |
376 alert(kind + ": " + arg); | 376 alert(kind + ": " + arg); |
377 for (; ls; ls = ls.next) | 377 for (; ls; ls = ls.next) |
378 try { | 378 try { |
379 exec({c:"a", f:{c:"a", f:{c:"c", v:ls.data}, x:{c:"c", v:arg}}, x:{c:"c", v:null}}); | 379 exec({c:"a", f:{c:"a", f:ls.data, x:{c:"c", v:arg}}, x:{c:"c", v:null}}); |
380 } catch (v) { } | 380 } catch (v) { } |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 var errorHandlers = null; | 384 var errorHandlers = null; |
385 | 385 |
386 function flift0(v) { | |
387 return {c:"c", v:v}; | |
388 } | |
389 | |
386 function onError(f) { | 390 function onError(f) { |
387 errorHandlers = cons(f, errorHandlers); | 391 errorHandlers = cons(flift0(f), errorHandlers); |
388 } | 392 } |
389 | 393 |
390 function er(s) { | 394 function er(s) { |
391 runHandlers("Error", errorHandlers, s); | 395 runHandlers("Error", errorHandlers, s); |
392 throw {uw_error: s}; | 396 throw {uw_error: s}; |
393 } | 397 } |
394 | 398 |
395 var failHandlers = null; | 399 var failHandlers = null; |
396 | 400 |
397 function onFail(f) { | 401 function onFail(f) { |
398 failHandlers = cons(f, failHandlers); | 402 failHandlers = cons(flift0(f), failHandlers); |
399 } | 403 } |
400 | 404 |
401 function doExn(v) { | 405 function doExn(v) { |
402 if (v == null || v.uw_error == null) { | 406 if (v == null || v.uw_error == null) { |
403 var s = (v == null ? "null" : v.message ? v.message : v.toString()); | 407 var s = (v == null ? "null" : v.message ? v.message : v.toString()); |
432 } | 436 } |
433 | 437 |
434 var serverHandlers = null; | 438 var serverHandlers = null; |
435 | 439 |
436 function onServerError(f) { | 440 function onServerError(f) { |
437 serverHandlers = cons(f, serverHandlers); | 441 serverHandlers = cons(flift0(f), serverHandlers); |
438 } | 442 } |
439 | 443 |
440 function servErr(s) { | 444 function servErr(s) { |
441 window.setTimeout(function () { runHandlers("Server", serverHandlers, s); }, 0); | 445 window.setTimeout(function () { runHandlers("Server", serverHandlers, s); }, 0); |
442 } | 446 } |