View Source

[examples]
context.wtcl
cookies.wtcl
cookiesIntro.wtcl
errors.wtcl
errorsIntro.wtcl
expr.wtcl
fish.jpg
fish.wtcl
flush.wtcl
flushIntro.wtcl
form.wtcl
formIntro.wtcl
index.wtcl
ready.wtcl
scripting.wtcl
scripting.wtcl~
scriptingIntro.wtcl
session.wtcl
sessionIntro.wtcl
uploads/
uploads.wtcl
uploadsIntro.wtcl
virtual.wtcl
virtualIntro.wtcl
File: / examples / errors.wtcl

Lines Size Modified Created Owner MIME Types
43 1,040 2010/05/18 23:04:06 2011/06/13 15:35:16 BUILTIN\Administrators application/x-wtcl, text/x-wtcl

0001
<?
0002
0003
include ../lib/examplePage.wtcl
0004
0005
proc ::myErrorHandler {} {
0006
  set buf "<html>\n<head><title>Error</title></head>\n<body>\n"
0007
  append buf "<h1>My Error Handler</h1>"
0008
0009
  set errors ""
0010
  set notices [::wt::server::taskNotices]
0011
  foreach notice $notices {
0012
    foreach {level msg} $notice {}
0013
    if {$level <= [::wt::server::logLevel code error]} {
0014
      append errors "<p>[::wt::web::htmlEncode $msg]</p>" 
0015
    }
0016
  }
0017
0018
  if {$errors != ""} {
0019
    append buf "<p>Sorry, an error occurred while processing this request:</p>"
0020
    append buf "<p><ul><pre>"
0021
    append buf $errors
0022
    append buf "</ul></pre></p>"
0023
  } else {
0024
    append buf "<p>Sorry, an error occurred while processing this request.</p>"
0025
  }
0026
0027
  append buf "<p>The administrator has been notified.</p>"
0028
  append buf "<p>Date: "
0029
  append buf [clock format [clock seconds] -format "%Y-%m-%d %T %Z"]
0030
  append buf "</p>\n"
0031
0032
  puts $buf
0033
0034
  flush stdout
0035
}
0036
0037
::wt::examples::setTitle "Error Handling"
0038
0039
::wt::server::events addHandler error ::myErrorHandler
0040
0041
error "This is some error."
0042
0043
?>