summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-12-04 15:13:53 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-12-04 15:13:53 -0500
commit70e17f78838ac1ebdeae9eca750eb52f14c27589 (patch)
tree13f7dbfad5476e358d258573ba563f0f18451ec4
parent226fb11ff2da90b7b68dad1b29b9688f880a06a3 (diff)
Stop [read] from raising an exception for invalid [int] strings
-rw-r--r--lib/js/urweb.js2
-rw-r--r--tests/parseInt.ur9
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index c6e55907..a10c107f 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -972,7 +972,7 @@ function trimZeroes(s) {
if (s == "0")
return s;
else
- er("Can't parse int: " + s);
+ return {};
}
function pi(s) {
diff --git a/tests/parseInt.ur b/tests/parseInt.ur
new file mode 100644
index 00000000..2d906fc8
--- /dev/null
+++ b/tests/parseInt.ur
@@ -0,0 +1,9 @@
+fun main () : transaction page =
+ s <- source "";
+ return <xml><body>
+ <ctextbox source={s}/>
+ <button onclick={n <- get s;
+ case read n of
+ None => alert "Invalid"
+ | Some n => alert (show (n + 1))}/>
+ </body></xml>