---
title: Central error handling
summary: Logs and e-mails an unhandled error, then redirects to an appropriate error page with an HTML-encoded message.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.MVC
reference_type: package
operation_id: OP-MVC-11
trigger: Delegated from Page error processing, or called directly by a derived controller
---

# Central error handling

The terminal error-handling operation for every SAIF WebForms screen: it logs the error with model/context detail, e-mails the support distribution list, and redirects the browser to an environment-appropriate error page with a sanitized message.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-MVC-11 |
| **Trigger** | Delegated from [Page error processing](page-error-processing.md), or called directly |
| **Inputs** | Exception, model, context |
| **Outputs** | Logged/e-mailed error; redirect to the error page with an encoded message |
| **Primary components** | `clsControllerBase.HandleErrors` |
| **Entry point** | SAIF.Presentation.Web.MVC/clsControllerBase.vb |

## Steps

1. Read the support distribution list from `EnvironmentService.GetConfigSetting("policymanagement.supportemaillist")` ([BR-MVC-024](../business-rules.md#br-mvc-024-every-framework-handled-error-is-logged-and-e-mailed-to-support)).
   - If the setting is missing: the value is passed through as-is with no guard, which can turn a handled error into a secondary failure inside the error handler.*
2. Call `clsLogError.CreateErrorWithEmail(smTo, ex, model, context)` — logs the error and e-mails support with model/context detail ([BR-MVC-024](../business-rules.md#br-mvc-024-every-framework-handled-error-is-logged-and-e-mailed-to-support)).
3. Resolve the error page from `AppSettings("ErrorPageName")` ([BR-MVC-025](../business-rules.md#br-mvc-025-the-error-page-falls-back-by-network-zone-when-unconfigured)).
   - If absent: choose `http://saifonline/weberror/processerror.aspx` for internal callers (`10.*.*.*`) or `https://saifonline.saif.com/weberror/processerror.aspx` otherwise.
4. HTML-encode the exception message and strip CR/LF characters ([BR-MVC-026](../business-rules.md#br-mvc-026-error-messages-are-html-encoded-before-redirect)).
5. Redirect to `<errpage>?MSG=<message>&Return=<current local path>` ([BR-MVC-012](../business-rules.md#br-mvc-012-redirect-induced-thread-aborts-are-suppressed)).
   - On failure: `ThreadAbortException` is caught (with `ResetAbort`) and `Response.End()` runs in `Finally`.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([HandleErrors]) --> S1[Read support e-mail list setting]
	S1 --> S2[CreateErrorWithEmail: log + notify support]
	S2 --> D1{ErrorPageName configured?}
	D1 -->|Yes| S3[Use configured error page]
	D1 -->|No, internal caller| S4[Use intranet error page]
	D1 -->|No, external caller| S5[Use public HTTPS error page]
	S3 --> S6[HTML-encode message, strip CR/LF]
	S4 --> S6
	S5 --> S6
	S6 --> EndOk([Redirect to error page with MSG + Return])
```

## Failure and edge-case behavior
- A missing support e-mail list setting is passed straight to `clsLogError.CreateErrorWithEmail` with no null guard, risking a secondary failure inside the error handler.*
- Redirect-induced `ThreadAbortException`s are suppressed the same way as elsewhere in the framework so the redirect itself never surfaces as a second error.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

## Sources
- SAIF.Presentation.Web.MVC/clsControllerBase.vb
