Themelia Pro A powerful new development platform built on ASP.NET.
 
Understanding Error Processors
 
 

In addition to the other types of processors, including pipeline processors, Themelia Pro provides a type of processor called an error processor. This type of processor allows you to create packages, reusable logic that will be run whenever a web domain throws an unhandled exception. In addition, Themelia Pro includes a few error processors which you may use out-of-the-box.

An erorr processor is made by creating a class that inherits from the Themelia.Web.Processing.ErrorProcessorBase abstract class. This class requires that you implement the following method signature:

void Execute(System.Web.HttpContext context, params Object[] parameterArray)

Here is an example of an error processor:

public class SavingErrorProcessor : Themelia.Web.Processing.ErrorProcessorBase
{
    public override void Execute(System.Web.HttpContext context, params Object[] parameterArray)
    {
        Exception ex = context.Error;
        if (ex != null && !Http.UrlPartArray.Contains("problem"))
        {
            String problemGuid = Web.ExceptionSaver.Save(ex);
            Http.Redirect("/problem/" + problemGuid);
        }
        else
        {
            try
            {
                Themelia.Reporting.ReportFacade.Send("Unknown exception occurred");
            }
            catch
            {
                //++ just in case the sample web.config isn't configured for mail
            }
        }
    }
}

When registered into a web domain, this somewhat complex error processor will check to see what endpoint is currently being accessed. If it's not the /problem endpoint, then the error was thrown from somewhere in our application. The processor will then save the exception thrown using custom logic and send the user to the /problem endpoint with the endpoint as a URL parameter (i.e. /problem/9427F1A9-6AAE-4f7e-81F6-3EE3B44C22CC), so the user can add more information to the error report. If the error processor is run from the /problem endpoint, then there was probably a problem saving the error and an alternate route is taken.

Error processors can be simple as a quick database saving or something more complex like what just shown.

To register an error processor, you add an entry to the processors collection just like you do with pipeline processors:

<themelia.web>
  <webDomains>
    <add>
      <processors>
        <add type="Sample.Web.Processing.SavingErrorProcessor, Sample.Web" />
      </processors>
    </add>
  </webDomains>
</themelia.web>

This, however, is not the recommended way. It's very highly recommended that all processors be loaded via a processor factory.

Error Processors in Web Domain Inheritance

Error processors obey the rules of web domain inheritance. In the following example, we have three web domains each with its own configuration (remember, in reality you would have a processor factory installed into the web domains):

<themelia.web>
  <webDomains>
    <add>
      <processors>
        <add type="Sample.Web.Routing.SavingErrorProcessor, Sample.Web" />
      </processors>
    </add>
    <add name="sales" path="sales">
      <processors>
        <add type="EmailSendingErrorProcessor" />
      </processors>
    </add>
    <add name="finance" path="finance" basedOn="sales">
      <processors>
        <add type="Sample.Web.Routing.DatabaseSavingErrorProcessor, Sample.Web" />
      </processors>
    </add>
  </webDomains>
</themelia.web>

When the root web domain has an error, the exception is handled as we previously explained. If the sales web domain has a problem, the exception is handles by sending an alert immediately. Finally, notice the finance web domain is based on the sales web domain. Thus, when an error is raised in the finance web domain, an email is sent immediately and the error is saved to the database (assuming thats what the DatabaseSavingErrorProcessor does.)

To be clear, this does NOT mean that sales errors will go to the finance web domain. Web domain inheritance just copies configuration and maintains the protective boundaries. Thus each web domain will see only its own exceptions.

Component Installation

also mention accessing parameters from the error processor