Log exception¶
This is the library's primary error-recording path. It captures runtime context, flattens a possibly nested exception into a single formatted payload, discards known ASP.NET ViewState noise before it ever reaches a sink, and then writes any remaining error to the configured file sink or the remote logging SOAP service.
| Field | Value |
|---|---|
| Operation ID | LOG-OP-002 |
| Trigger | Caller invokes clsLogError.CreateError(...). |
| Inputs | Exception plus optional state objects. |
| Outputs | Boolean; False only when the ViewState suppression filter matches, otherwise True even if the downstream write itself fails. |
| Primary components | clsLogError.CreateError, clsLogError.GetErrorData, clsLogError.ExceptionToString, clsLogError.WriteMessage |
| Entry point | SAIF.Framework.Logging/clsLogError.vb |
Steps¶
- Enter the outer
Try...CatchinCreateError(...)so that any downstream failure is contained inside the logging library and never reaches the caller (BR-005). - Construct
New clsLogError(inException, inStateInfo)to assemble the error payload. GetErrorData()captures machine, application, page, and environment fields fromHttpContextfor web callers orProcess.MainModulefor non-web callers, stampsErrorDate = Now, and constructs the matchingclsSecurityPrincipalplatform instance.- When
Secprinc.IsAuthenticatedisTrue, copySecprinc.UserNameintoUsername; otherwise leave it empty. ExceptionToString(...)walks to the innermost exception first, records itsSource(orUNKNOWNwhen absent), then appends each exception's message, source, and stack trace usingEXCEPTIONINFOFORMAT.- Serialize any supplied
inStateInfoobjects throughclsLogCommon.GetStateInfo(...)and store the result inStateInfo. - On failure: helper-level exceptions are swallowed, and whatever fields were already populated are returned as-is (BR-005).
Origin: The current-user lookup in step 2 delegates to
clsSecurityPrincipal, documented in Principal identity initialization (SAIF.Framework.Security). 3. RunSuppressLogging()againstErrorInfo.ExceptionInfoand stop immediately, returningFalse, when the formatted text containsAUTHENTICATION OF VIEWSTATE FAILEDorINVALID_VIEWSTATE_CLIENT_DISCONNECTED(BR-004). 4. When the error is not suppressed, route it throughWriteMessage(). - Ifm_OutFile Is Nothing, resolveloggingServiceUrl, constructwsLogging.clsWSLogging, map the payload intowsLogging.ErrorInfoStruct, callWriteError(...), dispose the proxy, and swallow any resulting exception (BR-005). - Otherwise appendErrorInfoStruct.ToCSVString()to the open file writer and flush it.Origin: The
loggingServiceUrllookup in step 4 delegates to Environment API configuration retrieval, summarized in Retrieve a configuration setting (SAIF.Framework.Security.EnvironmentApi). 5. ReturnTrueafter the write attempt completes, or after the outer catch absorbs an unexpected exception — either way, the caller never has to handle a logging failure itself (BR-005).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([CreateError request]) --> Build[Build ErrorInfoStruct and exception text]
Build --> Suppress{ViewState signature found?}
Suppress -->|Yes| EndDrop([Return False])
Suppress -->|No| Sink{File sink active?}
Sink -->|Yes| FileWrite[Append CSV row and flush]
Sink -->|No| Resolve[Resolve loggingServiceUrl]
Resolve --> SoapWrite[Call wsLogging.WriteError]
FileWrite --> EndOk([Return True])
SoapWrite --> EndOk
Failure and edge-case behavior¶
- ViewState-disconnect and ViewState-authentication failures are intentionally dropped before either sink is touched, keeping this class of noise out of both the log file and the SOAP endpoint (BR-004).
- The method returns
Trueafter most failures, because the outer catch swallows unexpected exceptions rather than propagating them — aTrueresult does not guarantee the error was actually persisted (BR-005). - When a file sink is active, the remote SOAP path is skipped entirely for that call.
Related documentation¶
Sources¶
SAIF.Framework.Logging/clsLogError.vbSAIF.Framework.Logging/ErrorInfoStruct.vbSAIF.Framework.Logging/clsLogCommon.vbSAIF.Framework.Security/clsSecurityPrincipal.vbSAIF.Framework.Security.EnvironmentApi/Services.Common/EnvironmentServiceBase.csSAIF.Framework.Security.EnvironmentApi/Services.Common/EnvironmentConfigKeys.cs