---
title: Error handling
summary: Centralizes unhandled-exception routing, logging, e-mail notification, and redirect to a configurable error page.
status: draft
owner: SAIF Documentation Team
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.MVC
reference_type: package
operation_id: OP-MVC-005
trigger: ViewPageBase.Page_Error
---

# Error handling

`ViewPageBase.ProcessError` intercepts any unhandled exception raised during a page's lifecycle, gives the concrete application a chance to handle it, dispatches on SAIF-specific exception types, and otherwise delegates to `clsControllerBase.HandleErrors` for logging, e-mail notification, and redirect to a central error page.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-MVC-005 |
| **Trigger** | `ViewPageBase.Page_Error`, calling `ProcessError(ex)` |
| **Inputs** | The unhandled exception |
| **Outputs** | User-facing message and/or redirect |
| **Primary components** | `ViewPageBase.ProcessError`, `clsControllerBase.HandleErrors` |
| **Entry point** | SAIF.Presentation.Web.MVC\ViewPageBase.aspx.vb |

## Steps

1. If `m_controller` is `Nothing`, rethrow the original exception.
2. Call the overridable `HandleApplicationError(ex)` hook.
   - If it returns `True`: no further action is taken (the application handled it).
3. Otherwise, if the exception's runtime type name is `clsSAIFException` (checked via reflection), read its `SAIFExceptionType` property and branch:
   - `TimeOutException` → set a "Database Timeout" message, log via `clsLogError.CreateError`, then navigate to `Default.aspx` with the encoded message appended as the `MSG` query-string parameter.
   - `DatabaseNotAvailableException` → set a "Database currently unavailable" message, log, then navigate to `Default.aspx` with the encoded message appended as the `MSG` query-string parameter.
   - Any other `clsSAIFException` subtype → delegate to `clsControllerBase.HandleErrors(ex)` (step 5).
4. If the exception is not a `clsSAIFException`, delegate directly to `clsControllerBase.HandleErrors(ex)` (step 5).
5. `clsControllerBase.HandleErrors(ex)`:
   - Sends an e-mail and logs via `clsLogError.CreateErrorWithEmail`, with the recipient list resolved from the `policymanagement.supportemaillist` configuration key.
   - Resolves an error page: `AppSettings["ErrorPageName"]` if configured, else a hardcoded internal (`http://saifonline/weberror/processerror.aspx`) or external (`https://saifonline.saif.com/weberror/processerror.aspx`) SAIF error URL based on the client's host address.
   - HTML-encodes the exception message and redirects to the resolved error page with `MSG=` and `Return=` query parameters, then ends the response.
   - On failure: `ThreadAbortException` from the redirect is swallowed via `Thread.ResetAbort()`.

## Process flow

```mermaid
flowchart TD
	Start([Page_Error]) --> NullCheck{m_controller is Nothing?}
	NullCheck -->|Yes| Rethrow([Rethrow original exception])
	NullCheck -->|No| AppHandler[HandleApplicationError hook]
	AppHandler --> Handled{Returns True?}
	Handled -->|Yes| End([No further action])
	Handled -->|No| SaifType{Is clsSAIFException?}
	SaifType -->|TimeOutException| TimeoutMsg[Log + navigate: Database Timeout]
	SaifType -->|DatabaseNotAvailableException| DbMsg[Log + navigate: Database unavailable]
	SaifType -->|Other SAIF type| HandleErrors[clsControllerBase.HandleErrors]
	SaifType -->|Not a SAIF exception| HandleErrors
	HandleErrors --> Email[Log + email via clsLogError.CreateErrorWithEmail]
	Email --> ResolvePage[Resolve error page URL]
	ResolvePage --> Redirect([Redirect with MSG and Return params])
```

## Failure and edge-case behavior
- If `HandleApplicationError(ex)` itself throws, the resulting exception is not caught by this operation — it propagates to the ASP.NET runtime's default error handling.
- The `clsSAIFException` type check is reflection-based (runtime type name comparison), not a compile-time `TypeOf` check, since `clsSAIFException` is not referenced by this library's assembly.
- `HandleErrors` always attempts to send an e-mail via `clsLogError.CreateErrorWithEmail`, even for high-frequency errors — no throttling or deduplication exists in this library.

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

## Sources
- SAIF.Presentation.Web.MVC\ViewPageBase.aspx.vb
- SAIF.Presentation.Web.MVC\clsControllerBase.vb
