summaryrefslogtreecommitdiffabout
path: root/htdocs/exceptions
Side-by-side diff
Diffstat (limited to 'htdocs/exceptions') (more/less context) (ignore whitespace changes)
-rw-r--r--htdocs/exceptions/compile.chtml50
-rw-r--r--htdocs/exceptions/development/.htaccess3
-rw-r--r--htdocs/exceptions/development/.scrc2
-rw-r--r--htdocs/exceptions/development/compile.chtml12
-rw-r--r--htdocs/exceptions/development/compile.html248
-rw-r--r--htdocs/exceptions/development/erroneous.h1
-rw-r--r--htdocs/exceptions/development/preprocess.chtml14
-rw-r--r--htdocs/exceptions/development/runtime.chtml16
-rw-r--r--htdocs/exceptions/index.chtml52
-rw-r--r--htdocs/exceptions/preprocess.chtml46
-rw-r--r--htdocs/exceptions/production/.htaccess3
-rw-r--r--htdocs/exceptions/production/.scrc2
-rw-r--r--htdocs/exceptions/production/compile.chtml12
-rw-r--r--htdocs/exceptions/production/compile.html44
-rw-r--r--htdocs/exceptions/production/erroneous.h1
-rw-r--r--htdocs/exceptions/production/preprocess.chtml14
-rw-r--r--htdocs/exceptions/production/runtime.chtml16
-rw-r--r--htdocs/exceptions/runtime.chtml47
18 files changed, 583 insertions, 0 deletions
diff --git a/htdocs/exceptions/compile.chtml b/htdocs/exceptions/compile.chtml
new file mode 100644
index 0000000..90ee7d8
--- a/dev/null
+++ b/htdocs/exceptions/compile.chtml
@@ -0,0 +1,50 @@
+% html(); return; /* vim:set ft=sitecing: */
+%%derive layout = "/ancestry/layout.chtml";
+<%constructor>
+ b_strict = false;
+</%constructor>
+<%codemethod string title() %>
+ return "compile-time exceptions handling";
+</%codemethod>
+<%method void content() %>
+ <h1>site-C-ing compile-time exception handling</h1>
+ <p>
+ Similar to <a href="/exceptions/preprocess">preprocessing exceptions</a>
+ there is a wide range of errors you may put into your code which will pass
+ through preprocessor and will be caught later at the compile-time.
+ </p>
+ <p>
+ Once you complete writing your <a
+ href="/view/htdocs/exceptions/development/compile.chtml" target="insert"
+ title="the link opens in the frame below">erroneous code</a> and
+ <em>site-C-ing</em> is done preprocessing it, it will feed the preprocessed
+ code into c++ compiler which will refuse to compile the code like this. This
+ is where <a href="/view/htdocs/handlers/exception_dev" target="insert"
+ title="the link opens in the frame below">the exception handler</a>,
+ specified in <a href="/view/htdocs/exceptions/development/.scrc"
+ target="insert" title="the link opens in the frame below">the configuration
+ file</a>, takes over the process and gives you <a
+ href="/exceptions/development/compile" target="insert" title="the link opens
+ in the frame below">the report</a>. Like with any handler, you may wish to
+ set some <a href="/view/htdocs/handlers/exception_prod" target="insert"
+ title="the link opens in the frame below">different handler</a> in your <a
+ href="/view/htdocs/exceptions/production/.scrc" target="insert" title="the
+ link opens in the frame below">production configuration</a>, which just gives
+ user <a href="/exceptions/production/preprocess" target="insert" title="the
+ link opens in the frame below">a friendly yet lame excuse</a>.
+ </p>
+ <p class="note">
+ Note, that these output pages are fakes -- I do not want to spawn the
+ compiler each time you want to see the output and put this unnecessary load
+ on cpu. These static pages are in fact saved output of the real exception
+ handlers.
+ </p>
+
+ <div class="insert">
+ <iframe id="insert" name="insert" src="about:blank" width="95%" height="300" border="1">
+ <p>I wanted to put an &lt;iframe&gt; here, but your browser does not seem to
+ support it. That is okay, it still will open links somehow.</p>
+ </iframe>
+ </div>
+
+</%method>
diff --git a/htdocs/exceptions/development/.htaccess b/htdocs/exceptions/development/.htaccess
new file mode 100644
index 0000000..01cb5ec
--- a/dev/null
+++ b/htdocs/exceptions/development/.htaccess
@@ -0,0 +1,3 @@
+<Files compile.chtml>
+ deny from all
+</Files>
diff --git a/htdocs/exceptions/development/.scrc b/htdocs/exceptions/development/.scrc
new file mode 100644
index 0000000..da24ef7
--- a/dev/null
+++ b/htdocs/exceptions/development/.scrc
@@ -0,0 +1,2 @@
+ExceptionHandler /handlers/exception_dev
+AutoBuildFiles -*
diff --git a/htdocs/exceptions/development/compile.chtml b/htdocs/exceptions/development/compile.chtml
new file mode 100644
index 0000000..3611ca9
--- a/dev/null
+++ b/htdocs/exceptions/development/compile.chtml
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title>I'm gonna make a number of mistakes!</title>
+ </head>
+ <body>
+% ind a = 2;
+% #include "erroneous.h"
+% unsigned int a = -1;
+% int j = k;
+ </body>
+</html>
+% /* vim:set ft=sitecing: */
diff --git a/htdocs/exceptions/development/compile.html b/htdocs/exceptions/development/compile.html
new file mode 100644
index 0000000..c3384a2
--- a/dev/null
+++ b/htdocs/exceptions/development/compile.html
@@ -0,0 +1,248 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+ <head>
+ <title>failed to compile component</title>
+ <style type="text/css">
+ <!--
+ body {
+ font-family: sans-serif;
+ font-size: 11pt;
+ }
+
+ h1 {
+ font-family: serif;
+ font-size: 130%;
+ font-weight: bold;
+ text-align: center;
+ }
+ p {
+ text-indent: 2em;
+ text-align: justify;
+ }
+
+ dl.exception-props {
+ margin: 1ex 1em;
+ padding: 0.5ex;
+ border: solid 1px gray;
+ background-color: #e0e0e0;
+ }
+ dl.exception-props dt {
+ font-weight: bold;
+ color: blue;
+ }
+ dl.exception-props dd {
+ color: gray;
+ }
+
+ div.exception-codepoint-report {
+ border: solid 1px black;
+ margin: 0.5ex 1em 0.ex 3em;
+ }
+ div.exception-codepoint-report h3 {
+ display: block;
+ color: blue;
+ border-bottom: 3px double black;
+ padding: 0.3ex; margin: 0px;
+ background: #e0e0e0;
+ }
+ div.exception-codepoint-report ul {
+ padding: 0px;
+ margin: 0px;
+ background: #87fdff;
+ font-size: 70%;
+ }
+ div.exception-codepoint-report li {
+ font-family: monospace;
+ list-style-type: none;
+ white-space: pre;
+ overflow: hidden;
+ }
+ div.exception-codepoint-report li.focused {
+ color: red;
+ border-top: solid 1px red; border-bottom: solid 1px red;
+ }
+ div.exception-codepoint-report li .lineno {
+ padding-right: 0.5ex;
+ border-right: dotted black 1px;
+ }
+ div.exception-codepoint-report div.what {
+ border-top: double 3px black;
+ padding: 0.5ex 2em;
+ font-weight: bold; color: #4040c0;
+ overflow: auto;
+ }
+ div.backtrace div.exception-codepoint-report div.what {
+ color: gray;
+ }
+
+ div.exception-compile div.what {
+ font-weight: normal;
+ color: red;
+ }
+
+ div.powered {
+ margin: 2em 0px 0px 50%;
+ padding: 1ex 2ex;
+ text-align: right;
+ font-family: serif;
+ font-size: 140%;
+ font-weight: bold;
+ border-top: solid 2px black;
+ border-left: solid 1px gray; border-right: solid 1px gray; border-bottom: solid 1px gray;
+ background: #c0c0f0;
+ }
+ -->
+ </style>
+ </head>
+ <body>
+
+ <div class="exception-compile">
+ <h1>error compiling component '<code>exceptions/development/compile.chtml</code>'</h1>
+
+ <div class="exception-codepoint-report">
+ <h3>exceptions/development/compile.chtml</h3>
+ <ul>
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;<span class="line">&lt;html&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;<span class="line">&nbsp;&lt;head&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;<span class="line">&nbsp;&nbsp;&lt;title&gt;I'm&nbsp;gonna&nbsp;make&nbsp;a&nbsp;number&nbsp;of&nbsp;mistakes!&lt;/title&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;<span class="line">&nbsp;&lt;/head&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;<span class="line">&nbsp;&lt;body&gt;</span></li>
+
+ <li class="focused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;<span class="line">%&nbsp;&nbsp;ind&nbsp;a&nbsp;=&nbsp;2;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;<span class="line">%&nbsp;&nbsp;#include&nbsp;"erroneous.h"</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;<span class="line">%&nbsp;&nbsp;unsigned&nbsp;int&nbsp;a&nbsp;=&nbsp;-1;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;<span class="line">%&nbsp;&nbsp;int&nbsp;j&nbsp;=&nbsp;k;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;10</span>&nbsp;<span class="line">&nbsp;&lt;/body&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;11</span>&nbsp;<span class="line">&lt;/html&gt;</span></li>
+ </ul>
+ <div class="what">
+ exceptions/development/compile.chtml: In member function `virtual void _SCC_exceptions_development_compile_chtml::main(int, char*)':<br/>
+exceptions/development/compile.chtml:6: error: `ind' undeclared (first use this function)<br/>
+exceptions/development/compile.chtml:6: error: (Each undeclared identifier is reported only once for each function it appears in.)<br/>
+exceptions/development/compile.chtml:6: error: expected `;' before "a"
+ </div>
+ </div>
+
+ <div class="exception-codepoint-report">
+ <h3>exceptions/development/compile.chtml</h3>
+ <ul>
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;<span class="line">&nbsp;&lt;head&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;<span class="line">&nbsp;&nbsp;&lt;title&gt;I'm&nbsp;gonna&nbsp;make&nbsp;a&nbsp;number&nbsp;of&nbsp;mistakes!&lt;/title&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;<span class="line">&nbsp;&lt;/head&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;<span class="line">&nbsp;&lt;body&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;<span class="line">%&nbsp;&nbsp;ind&nbsp;a&nbsp;=&nbsp;2;</span></li>
+
+ <li class="focused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;<span class="line">%&nbsp;&nbsp;#include&nbsp;"erroneous.h"</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;<span class="line">%&nbsp;&nbsp;unsigned&nbsp;int&nbsp;a&nbsp;=&nbsp;-1;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;<span class="line">%&nbsp;&nbsp;int&nbsp;j&nbsp;=&nbsp;k;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;10</span>&nbsp;<span class="line">&nbsp;&lt;/body&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;11</span>&nbsp;<span class="line">&lt;/html&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;12</span>&nbsp;<span class="line">%&nbsp;/*&nbsp;vim:set&nbsp;ft=sitecing:&nbsp;*/</span></li>
+ </ul>
+ <div class="what">
+ In file included from exceptions/development/compile.chtml:7:
+ </div>
+ </div>
+
+ <div class="exception-codepoint-report">
+ <h3>exceptions/development/erroneous.h</h3>
+ <ul>
+ <li class="focused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;<span class="line">&nbsp;a+2=5;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;<span class="line"></span></li>
+ </ul>
+ <div class="what">
+ ./erroneous.h:1: error: `a' undeclared (first use this function)
+ </div>
+ </div>
+
+ <div class="exception-codepoint-report">
+ <h3>exceptions/development/compile.chtml</h3>
+ <ul>
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;<span class="line">&nbsp;&nbsp;&lt;title&gt;I'm&nbsp;gonna&nbsp;make&nbsp;a&nbsp;number&nbsp;of&nbsp;mistakes!&lt;/title&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;<span class="line">&nbsp;&lt;/head&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;<span class="line">&nbsp;&lt;body&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;<span class="line">%&nbsp;&nbsp;ind&nbsp;a&nbsp;=&nbsp;2;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;<span class="line">%&nbsp;&nbsp;#include&nbsp;"erroneous.h"</span></li>
+
+ <li class="focused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;<span class="line">%&nbsp;&nbsp;unsigned&nbsp;int&nbsp;a&nbsp;=&nbsp;-1;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;<span class="line">%&nbsp;&nbsp;int&nbsp;j&nbsp;=&nbsp;k;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;10</span>&nbsp;<span class="line">&nbsp;&lt;/body&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;11</span>&nbsp;<span class="line">&lt;/html&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;12</span>&nbsp;<span class="line">%&nbsp;/*&nbsp;vim:set&nbsp;ft=sitecing:&nbsp;*/</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;13</span>&nbsp;<span class="line"></span></li>
+ </ul>
+ <div class="what">
+ exceptions/development/compile.chtml:8: warning: converting of negative value `-0x000000001' to `unsigned int'
+ </div>
+ </div>
+
+ <div class="exception-codepoint-report">
+ <h3>exceptions/development/compile.chtml</h3>
+ <ul>
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;<span class="line">&nbsp;&lt;/head&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;<span class="line">&nbsp;&lt;body&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;<span class="line">%&nbsp;&nbsp;ind&nbsp;a&nbsp;=&nbsp;2;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;<span class="line">%&nbsp;&nbsp;#include&nbsp;"erroneous.h"</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;<span class="line">%&nbsp;&nbsp;unsigned&nbsp;int&nbsp;a&nbsp;=&nbsp;-1;</span></li>
+
+ <li class="focused"><span class="lineno">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;<span class="line">%&nbsp;&nbsp;int&nbsp;j&nbsp;=&nbsp;k;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;10</span>&nbsp;<span class="line">&nbsp;&lt;/body&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;11</span>&nbsp;<span class="line">&lt;/html&gt;</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;12</span>&nbsp;<span class="line">%&nbsp;/*&nbsp;vim:set&nbsp;ft=sitecing:&nbsp;*/</span></li>
+
+ <li class="unfocused"><span class="lineno">&nbsp;&nbsp;&nbsp;13</span>&nbsp;<span class="line"></span></li>
+ </ul>
+ <div class="what">
+ exceptions/development/compile.chtml:9: error: `k' undeclared (first use this function)<br/>
+
+ </div>
+ </div>
+
+ </div>
+
+ <div class="powered">Powered by <a href="http://kin.klever.net/sitecing/" title="site-C-ing">site-C-ing</a>.</div>
+ </body>
+</html>
+
+
+
+
+
+
+
diff --git a/htdocs/exceptions/development/erroneous.h b/htdocs/exceptions/development/erroneous.h
new file mode 100644
index 0000000..060a57e
--- a/dev/null
+++ b/htdocs/exceptions/development/erroneous.h
@@ -0,0 +1 @@
+ a+2=5;
diff --git a/htdocs/exceptions/development/preprocess.chtml b/htdocs/exceptions/development/preprocess.chtml
new file mode 100644
index 0000000..f7405e7
--- a/dev/null
+++ b/htdocs/exceptions/development/preprocess.chtml
@@ -0,0 +1,14 @@
+<html>
+ <body>
+ <p>
+ I was writing this component in a hurry, having a lot of things to distract
+ me, so no wonder I made mistake.
+ <%code>
+ /* I do not even remember what I was going to put in this code block. And
+ * of course I didn't mean to forget that this is just a block of code, not
+ * a constructor...
+ */
+ </%constructor>
+ </p>
+ </body>
+</html>
diff --git a/htdocs/exceptions/development/runtime.chtml b/htdocs/exceptions/development/runtime.chtml
new file mode 100644
index 0000000..4a494bd
--- a/dev/null
+++ b/htdocs/exceptions/development/runtime.chtml
@@ -0,0 +1,16 @@
+%%decl #include <konforka/exception.h>
+<%code>
+ try{
+ try{
+ try{
+ throw konforka::exception(CODEPOINT,"throwing an exception to backtrace a bit");
+ }catch(konforka::exception& ke){
+ ke.see(CODEPOINT); throw;
+ }
+ }catch(konforka::exception& ke){
+ ke.see(CODEPOINT); throw;
+ }
+ }catch(konforka::exception& ke){
+ ke.see(CODEPOINT); throw;
+ }
+</%code>
diff --git a/htdocs/exceptions/index.chtml b/htdocs/exceptions/index.chtml
new file mode 100644
index 0000000..cc0ed8a
--- a/dev/null
+++ b/htdocs/exceptions/index.chtml
@@ -0,0 +1,52 @@
+% html(); return; /* vim:set ft=sitecing: */
+%%derive layout = "/ancestry/layout.chtml";
+<%codemethod string title() %>
+ return "exceptions handling";
+</%codemethod>
+<%method void content() %>
+ <h1>site-C-ing exception handling</h1>
+ <p>
+ The purpose of this section is to give an overview of the <em>site-C-ing</em>
+ exception handling mechanism. Before the web visitor can see the page each
+ site-C-ing component goes through a few stages, namely, preprocessing,
+ compiling and execution. Having three stages to go through also means the
+ stages one can fail to go through and three exciting opportunities to handle
+ different errors.
+ </p>
+ <p>
+ First each component is preprocessed so that you can feed the valid c++ code
+ to the compiler. Here is where the preprocessor can choke at your broken
+ source code. Once preprocessor failes to parse your code it will throw an
+ exception which <em>site-C-ing</em> will catch and pass to <a
+ href="/sources/htdocs/handlers/exception_dev" title="development mode
+ exception handler source">the exception handler component</a>. Want to <a
+ href="/exceptions/preprocess">read more</a> about preprocessor exception
+ handling?
+ </p>
+ <p>
+ After the preprocessing stage is over we have a great opportunity to catch
+ the compile-time errors. After <em>site-C-ing</em> fails to compile the
+ component it throws another exception and passes it to the same handler which
+ may show you some information on what's gone wrong with your source code from
+ the compiler's perspective. If you've gone this far you definitely want to <a
+ href="/exceptions/compile">read more</a> about the compiler error handling.
+ </p>
+ <p class="note">
+ Note, that it is likely that you will want to disable the steps above for the
+ production environment to save time on unnecessary checking whether the
+ component is up to date.
+ </p>
+ <p>
+ Finally, we need to execute the component and present its output to the web
+ site visitor. This is also where things may go wrong and here is where your
+ component may throw an exception for the engine to catch and pass to the
+ handler. Feel free to <a href="/exceptions/runtime">learn more</a> about it
+ as well.
+ </p>
+ <p class="note">
+ One more thing you will likely want to have differently in production
+ environment is <a href="/sources/htdocs/handlers/exception_prod"
+ title="production mode exception handler source">an exception handler</a>
+ which will not give out that much unnecessary information to the user.
+ </p>
+</%method>
diff --git a/htdocs/exceptions/preprocess.chtml b/htdocs/exceptions/preprocess.chtml
new file mode 100644
index 0000000..8516139
--- a/dev/null
+++ b/htdocs/exceptions/preprocess.chtml
@@ -0,0 +1,46 @@
+% html(); return; /* vim:set ft=sitecing: */
+%%derive layout = "/ancestry/layout.chtml";
+<%constructor>
+ b_strict = false;
+</%constructor>
+<%codemethod string title() %>
+ return "preprocessor exceptions handling";
+</%codemethod>
+<%method void content() %>
+ <h1>site-C-ing preprocessor exception handling</h1>
+ <p>
+ It was one of those days when you just can't type right and can't think of
+ what you're typing. It is not unusual that, under such circumstances, you end
+ up with a code like <a
+ href="/view/htdocs/exceptions/development/preprocess.chtml" target="insert"
+ title="the link opens in the frame below">this</a> -- by the time you were
+ about to close your <code>&lt;%code&gt;</code> block you were thinking about
+ some constructor in some component elsewhere in the universe.
+ </p>
+ <p>
+ <em>site-C-ing</em> parser will see the inconsistency and throw an exception
+ which will be caught and passed to <a
+ href="/view/htdocs/handlers/exception_dev" target="insert" title="the link
+ opens in the frame below">the handler</a>, specified in <a
+ href="/view/htdocs/exceptions/development/.scrc" target="insert" title="the
+ link opens in the frame below">the configuration file</a>, which will produce
+ some nice, human-readable <a href="/exceptions/development/preprocess"
+ target="insert" title="the link opens in the frame below">output</a>. Well,
+ you may not wish to give out all this information in the production
+ environment, so you just put in your <a
+ href="/view/htdocs/exceptions/production/.scrc" target="insert" title="the
+ link opens in the frame below">configuration file</a> some <a
+ href="/view/htdocs/handlers/exception_prod" target="insert" title="the link
+ opens in the frame below">different handler</a>, which just gives user <a
+ href="/exceptions/production/preprocess" target="insert" title="the link
+ opens in the frame below">a friendly yet lame excuse</a>.
+ </p>
+
+ <div class="insert">
+ <iframe id="insert" name="insert" src="about:blank" width="95%" height="300">
+ <p>I wanted to put an &lt;iframe&gt; here, but your browser does not seem to
+ support it. That is okay, it still will open links somehow.</p>
+ </iframe>
+ </div>
+
+</%method>
diff --git a/htdocs/exceptions/production/.htaccess b/htdocs/exceptions/production/.htaccess
new file mode 100644
index 0000000..01cb5ec
--- a/dev/null
+++ b/htdocs/exceptions/production/.htaccess
@@ -0,0 +1,3 @@
+<Files compile.chtml>
+ deny from all
+</Files>
diff --git a/htdocs/exceptions/production/.scrc b/htdocs/exceptions/production/.scrc
new file mode 100644
index 0000000..d97eeb4
--- a/dev/null
+++ b/htdocs/exceptions/production/.scrc
@@ -0,0 +1,2 @@
+ExceptionHandler /handlers/exception_prod
+AutoBuildFiles -*
diff --git a/htdocs/exceptions/production/compile.chtml b/htdocs/exceptions/production/compile.chtml
new file mode 100644
index 0000000..3611ca9
--- a/dev/null
+++ b/htdocs/exceptions/production/compile.chtml
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title>I'm gonna make a number of mistakes!</title>
+ </head>
+ <body>
+% ind a = 2;
+% #include "erroneous.h"
+% unsigned int a = -1;
+% int j = k;
+ </body>
+</html>
+% /* vim:set ft=sitecing: */
diff --git a/htdocs/exceptions/production/compile.html b/htdocs/exceptions/production/compile.html
new file mode 100644
index 0000000..faa0ab9
--- a/dev/null
+++ b/htdocs/exceptions/production/compile.html
@@ -0,0 +1,44 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+ <head>
+ <title>Server-side exception</title>
+ <style type="text/css">
+ <!--
+ body {
+ font-family: sans-serif;
+ font-size: 12pt;
+ }
+ h1 {
+ font-family: serif;
+ font-size: 130%;
+ font-weight: bold;
+ text-align: center;
+ }
+ p {
+ text-indent: 2em;
+ text-align: justify;
+ }
+
+ div.powered {
+ margin: 2em 0px 0px 50%;
+ padding: 1ex 2ex;
+ text-align: right;
+ font-family: serif;
+ font-size: 140%;
+ font-weight: bold;
+ border-top: solid 2px black;
+ border-left: solid 1px gray; border-right: solid 1px gray; border-bottom: solid 1px gray;
+ background: #c0c0f0;
+ }
+ -->
+ </style>
+ </head>
+ <body>
+ <h1>server-side exception</h1>
+ <p>Something has gone really wrong with the server. Feel free to report the
+ incident to <a href="mailto:root@localhost" title="e-mail
+ server administrator">webmaster</a>.</p>
+ <div class="powered">Powered by <a href="http://kin.klever.net/sitecing/" title="site-C-ing">site-C-ing</a>.</div>
+ </body>
+</html>
diff --git a/htdocs/exceptions/production/erroneous.h b/htdocs/exceptions/production/erroneous.h
new file mode 100644
index 0000000..060a57e
--- a/dev/null
+++ b/htdocs/exceptions/production/erroneous.h
@@ -0,0 +1 @@
+ a+2=5;
diff --git a/htdocs/exceptions/production/preprocess.chtml b/htdocs/exceptions/production/preprocess.chtml
new file mode 100644
index 0000000..f7405e7
--- a/dev/null
+++ b/htdocs/exceptions/production/preprocess.chtml
@@ -0,0 +1,14 @@
+<html>
+ <body>
+ <p>
+ I was writing this component in a hurry, having a lot of things to distract
+ me, so no wonder I made mistake.
+ <%code>
+ /* I do not even remember what I was going to put in this code block. And
+ * of course I didn't mean to forget that this is just a block of code, not
+ * a constructor...
+ */
+ </%constructor>
+ </p>
+ </body>
+</html>
diff --git a/htdocs/exceptions/production/runtime.chtml b/htdocs/exceptions/production/runtime.chtml
new file mode 100644
index 0000000..4a494bd
--- a/dev/null
+++ b/htdocs/exceptions/production/runtime.chtml
@@ -0,0 +1,16 @@
+%%decl #include <konforka/exception.h>
+<%code>
+ try{
+ try{
+ try{
+ throw konforka::exception(CODEPOINT,"throwing an exception to backtrace a bit");
+ }catch(konforka::exception& ke){
+ ke.see(CODEPOINT); throw;
+ }
+ }catch(konforka::exception& ke){
+ ke.see(CODEPOINT); throw;
+ }
+ }catch(konforka::exception& ke){
+ ke.see(CODEPOINT); throw;
+ }
+</%code>
diff --git a/htdocs/exceptions/runtime.chtml b/htdocs/exceptions/runtime.chtml
new file mode 100644
index 0000000..d0a8e14
--- a/dev/null
+++ b/htdocs/exceptions/runtime.chtml
@@ -0,0 +1,47 @@
+% html(); return; /* vim:set ft=sitecing: */
+%%derive layout = "/ancestry/layout.chtml";
+<%constructor>
+ b_strict = false;
+</%constructor>
+<%codemethod string title() %>
+ return "runtime exceptions handling";
+</%codemethod>
+<%method void content() %>
+ <h1>site-C-ing runtime exception handling</h1>
+ <p>
+ The component may throw an exception while executing and the
+ <em>site-C-ing</em> will gladly pass it to the handler component which will
+ give the user appropriate output (unless it throws an exception itself, of
+ course). Here you will see an example output provided by the handler bundled
+ with the <em>site-C-ing</em>.
+ </p>
+
+ <p>
+ Suppose you have <a href="/view/htdocs/exceptions/development/runtime.chtml"
+ target="insert" title="the link opens in the frame below">a component</a>,
+ which at some point throws an exception. Of course, <em>site-C-ing</em> will
+ catch the exception and pass it to <a
+ href="/view/htdocs/handlers/exception_dev" target="insert" title="the link
+ opens in the frame below">the handler</a>, specified in <a
+ href="/view/htdocs/exceptions/development/.scrc" target="insert" title="the
+ link opens in the frame below">the configuration file</a>, which will produce
+ some nice, human-readable <a href="/exceptions/development/runtime"
+ target="insert" title="the link opens in the frame below">output</a>. Well,
+ you may not wish to give out all this information in the production
+ environment, so you just put in your <a
+ href="/view/htdocs/exceptions/production/.scrc" target="insert" title="the
+ link opens in the frame below">configuration file</a> some <a
+ href="/view/htdocs/handlers/exception_prod" target="insert" title="the link
+ opens in the frame below">different handler</a>, which just gives user <a
+ href="/exceptions/production/runtime" target="insert" title="the link opens
+ in the frame below">a friendly yet lame excuse</a>.
+ </p>
+
+ <div class="insert">
+ <iframe id="insert" name="insert" src="about:blank" width="95%" height="300">
+ <p>I wanted to put an &lt;iframe&gt; here, but your browser does not seem to
+ support it. That is okay, it still will open links somehow.</p>
+ </iframe>
+ </div>
+
+</%method>