% html(); return; /* vim:set ft=sitecing: */ %%derive layout = "/ancestry/layout.chtml"; <%codemethod string title() %> return "exceptions handling"; <%method void content() %>

site-C-ing exception handling

The purpose of this section is to give an overview of the site-C-ing 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.

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 site-C-ing will catch and pass to the exception handler component. Want to read more about preprocessor exception handling?

After the preprocessing stage is over we have a great opportunity to catch the compile-time errors. After site-C-ing 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 read more about the compiler error handling.

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.

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 learn more about it as well.

One more thing you will likely want to have differently in production environment is an exception handler which will not give out that much unnecessary information to the user.