On Sun, Jul 15, 2012 at 10:39 AM, Stephan Beal <[email protected]>wrote:
> Which reminds me: now that th1 can access get/post args, the header,
> footer, and any docs/pages/commands we make th1-aware can behave more
> dynamically. For example:
>
th1 offers a cool "catch" feature which we can use to make the script more
robust. Combined with the "ob" API we can use it to implement an "all or
nothing" display behaviour which discards the contents if an error is
thrown from a script:
ob start
catch {
> set foo [argv getint foo "" 0]
> if { 0 == $foo } {
> ... default behaviour
> } else {
> render_doc doc_$foo
> }
>
return 0
} err
set content [ob get end]
if { 0 == $err } {
puts $content
}else {
puts "Error: $err"
}
with that in place, any error generated in the catch block will be safely
propagated back out and none of the generated content will be displayed -
it is instead replaced by an error message. The "ob" parts capture all the
output and let us decide at the end if we want to display them or not.
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users