// Token: 0x06000987 RID: 2439 RVA: 0x000220EC File Offset: 0x000202EC
        private static bool RemedyExceptionHandlingError(Exception exception, RequestContext requestContext, out string error, out Strings.IDs?errorMessageId, out bool siteMailbox)
        {
            DateTime?dateTime = null;

            error          = string.Empty;
            errorMessageId = null;
            siteMailbox    = ErrorHandlerUtilities.IsSharePointAppRequest(requestContext, out dateTime);
            if (siteMailbox)
            {
                if ((exception is ConnectionFailedTransientException && exception.InnerException is MapiExceptionLogonFailed) || (exception is AccessDeniedException || (exception is OwaExplicitLogonException && exception.InnerException is AccessDeniedException)) || (exception is InvalidSerializedAccessTokenException && exception.InnerException is ObjectNotFoundException))
                {
                    error          = Strings.GetLocalizedString(-1076784851);
                    errorMessageId = new Strings.IDs?(-1076784851);
                    return(true);
                }
                bool flag = dateTime == null || dateTime.Value.AddMinutes(30.0).ToUniversalTime() > DateTime.UtcNow;
                if (flag)
                {
                    error          = Strings.GetLocalizedString(825706319);
                    errorMessageId = new Strings.IDs?(825706319);
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
        // Token: 0x060011C6 RID: 4550 RVA: 0x00044898 File Offset: 0x00042A98
        private void OnError(object sender, EventArgs e)
        {
            ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "OwaModule.OnError");
            HttpApplication httpApplication = (HttpApplication)sender;
            Exception       lastError       = httpApplication.Server.GetLastError();

            if (lastError == null)
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "GetLastError returned null.  Bailing out.");
                return;
            }
            RequestContext requestContext = RequestContext.Current;

            if (requestContext.RequestType == OwaRequestType.Invalid)
            {
                requestContext.RequestType = RequestDispatcherUtilities.GetRequestType(requestContext.HttpContext.Request);
            }
            if (!RequestDispatcherUtilities.IsDownLevelClient(requestContext.HttpContext, true) && (RequestDispatcherUtilities.IsPremiumRequest(requestContext.HttpContext.Request) || requestContext.RequestType == OwaRequestType.Form15 || requestContext.RequestType == OwaRequestType.LanguagePost))
            {
                httpApplication.Server.ClearError();
                ErrorHandlerUtilities.HandleException(requestContext, lastError);
                return;
            }
            ErrorHandlerUtilities.RecordException(requestContext, lastError);
        }
Пример #3
0
 internal static void SendInstantMessageWatsonReport(IUserContext userContext, Exception exception)
 {
     Microsoft.Exchange.Clients.Owa.Server.LyncIMLogging.ExTraceGlobals.InstantMessagingTracer.TraceDebug(0L, "Exception: Type: {0} Error: {1}.", new object[]
     {
         exception.GetType(),
         exception.Message
     });
     if (Globals.SendWatsonReports)
     {
         Microsoft.Exchange.Clients.Owa.Server.LyncIMLogging.ExTraceGlobals.InstantMessagingTracer.TraceDebug(0L, "Sending watson report");
         ReportOptions options = (exception is AccessViolationException || exception is InvalidProgramException || exception is TypeInitializationException) ? ReportOptions.ReportTerminateAfterSend : ReportOptions.None;
         ExWatson.AddExtraData(InstantMessageUtilities.GetExtraWatsonData(userContext));
         ExWatson.SendReport(exception, options, null);
     }
     if (exception is AccessViolationException)
     {
         Microsoft.Exchange.Clients.Owa.Server.LyncIMLogging.ExTraceGlobals.InstantMessagingTracer.TraceDebug(0L, "Shutting down OWA due to unrecoverable exception");
         ErrorHandlerUtilities.TerminateProcess();
         return;
     }
     if ((exception is InvalidProgramException || exception is TypeInitializationException) && Interlocked.Exchange(ref InstantMessageUtilities.queuedDelayedRestart, 1) == 0)
     {
         new Thread(new ThreadStart(InstantMessageUtilities.DelayedRestartUponUnexecutableCode)).Start();
     }
 }
        // Token: 0x0600097C RID: 2428 RVA: 0x00020BB4 File Offset: 0x0001EDB4
        internal static void RecordException(RequestContext requestContext, Exception exception)
        {
            HttpContext httpContext = requestContext.HttpContext;

            ErrorHandlerUtilities.LogExceptionCodeInIIS(requestContext, exception);
            RequestDetailsLogger getRequestDetailsLogger = OwaApplication.GetRequestDetailsLogger;

            if (getRequestDetailsLogger != null && getRequestDetailsLogger.ActivityScope != null)
            {
                getRequestDetailsLogger.ActivityScope.SetProperty(ServiceCommonMetadata.GenericErrors, exception.ToString());
            }
            else
            {
                ExTraceGlobals.CoreTracer.TraceDebug <bool, bool, Exception>(0L, "Couldn't append exception to server log. Logger is null: {0}, logger.ActivityScope is null: {1}, Exception: {2}", getRequestDetailsLogger == null, getRequestDetailsLogger != null && getRequestDetailsLogger.ActivityScope == null, exception);
            }
            OwaServerTraceLogger.AppendToLog(new TraceLogEvent("ErrorHandlerUtilities", null, "RecordException", exception.ToString()));
            try
            {
                Exception baseException = ErrorHandlerUtilities.GetBaseException(exception);
                httpContext.Response.Headers.Add("X-OWA-Error", baseException.GetType().FullName);
                if (baseException is WrongServerException)
                {
                    string value = ((WrongServerException)baseException).RightServerToString();
                    if (!string.IsNullOrEmpty(value))
                    {
                        httpContext.Response.Headers.Add(WellKnownHeader.XDBMountedOnServer, value);
                    }
                }
            }
            catch (HttpException arg)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <HttpException, Exception>(0L, "Failed to add error headers to the response. {0}. Original exception: {1}", arg, exception);
            }
        }
 // Token: 0x06000982 RID: 2434 RVA: 0x0002145C File Offset: 0x0001F65C
 private static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     if (e.IsTerminating)
     {
         ErrorHandlerUtilities.RecycleAppPool();
     }
     ExWatson.HandleException(sender, e);
 }
Пример #6
0
        private static void LogException(Exception error)
        {
            if (!Globals.IsAnonymousCalendarApp)
            {
                RequestDetailsLogger.LogException(error, "OwaFaultHandler", "ProvideFault");
            }
            RequestContext requestContext = RequestContext.Current;

            if (requestContext != null)
            {
                ErrorHandlerUtilities.LogExceptionCodeInIIS(requestContext, error);
            }
        }
Пример #7
0
 // Token: 0x0600116C RID: 4460 RVA: 0x00042E12 File Offset: 0x00041012
 protected override void ExecuteApplicationSpecificStart()
 {
     ErrorHandlerUtilities.RegisterForUnhandledExceptions();
 }
Пример #8
0
 private static void DelayedRestartUponUnexecutableCode()
 {
     Thread.Sleep(90000);
     OwaDiagnostics.Logger.LogEvent(ClientsEventLogConstants.Tuple_OwaRestartingAfterFailedLoad, string.Empty, new object[0]);
     ErrorHandlerUtilities.TerminateProcess();
 }
        // Token: 0x06000983 RID: 2435 RVA: 0x00021474 File Offset: 0x0001F674
        private static ErrorInformation GetExceptionHandlingInformation(Exception exception, RequestContext requestContext)
        {
            bool sendWatsonReport = false;

            Strings.IDs?    messageId        = null;
            string          messageParameter = null;
            string          lids             = null;
            SupportLevel?   supportLevel     = null;
            IMailboxContext mailboxContext   = (requestContext != null) ? requestContext.UserContext : null;
            string          text             = string.Empty;

            if (mailboxContext != null)
            {
                text = mailboxContext.PrimarySmtpAddress.ToString();
            }
            string message;

            if (exception is OwaNotSupportedException)
            {
                message = exception.Message;
            }
            else if (exception is OwaIdentityException)
            {
                sendWatsonReport = false;
                message          = exception.Message;
            }
            else if (exception is OwaExistentNotificationPipeException)
            {
                message   = Strings.GetLocalizedString(1295605912);
                messageId = new Strings.IDs?(1295605912);
            }
            else if (exception is OwaNotificationPipeException)
            {
                message          = Strings.GetLocalizedString(-771052428);
                messageId        = new Strings.IDs?(-771052428);
                sendWatsonReport = false;
            }
            else if (exception is OwaOperationNotSupportedException)
            {
                message = exception.Message;
            }
            else if (exception is OwaADObjectNotFoundException)
            {
                OwaADUserNotFoundException ex = exception as OwaADUserNotFoundException;
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
                if (ex != null && !string.IsNullOrWhiteSpace(ex.UserName))
                {
                    message          = string.Format(Strings.GetLocalizedString(-765910865), ex.UserName);
                    messageId        = new Strings.IDs?(-765910865);
                    messageParameter = ex.UserName;
                }
                else
                {
                    message   = Strings.GetLocalizedString(-950823100);
                    messageId = new Strings.IDs?(-950823100);
                }
            }
            else if (exception is OwaLockTimeoutException || exception is BailOutException)
            {
                message   = Strings.GetLocalizedString(-116001901);
                messageId = new Strings.IDs?(-116001901);
                if (requestContext != null)
                {
                    requestContext.HttpContext.Response.AppendToLog("&s=ReqTimeout");
                }
            }
            else if (exception is ObjectExistedException)
            {
                message   = Strings.GetLocalizedString(-1399945920);
                messageId = new Strings.IDs?(-1399945920);
            }
            else if (exception is MailboxInSiteFailoverException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(26604436);
                messageId        = new Strings.IDs?(26604436);
                supportLevel     = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is MailboxCrossSiteFailoverException || exception is WrongServerException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(26604436);
                messageId        = new Strings.IDs?(26604436);
                supportLevel     = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is MailboxInTransitException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(-1739093686);
                messageId        = new Strings.IDs?(-1739093686);
                supportLevel     = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is ResourceUnhealthyException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(198161982);
                messageId        = new Strings.IDs?(198161982);
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_ErrorResourceUnhealthy, string.Empty, new object[]
                {
                    text,
                    exception.ToString()
                });
            }
            else if (exception is ConnectionFailedPermanentException || exception is ServerNotFoundException)
            {
                message          = string.Format(Strings.GetLocalizedString(-765910865), text);
                messageId        = new Strings.IDs?(-765910865);
                messageParameter = text;
                supportLevel     = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is ConnectionFailedTransientException || exception is MailboxOfflineException)
            {
                if (exception.InnerException is MapiExceptionLogonFailed && mailboxContext.IsExplicitLogon)
                {
                    message      = Strings.GetLocalizedString(882888134);
                    messageId    = new Strings.IDs?(882888134);
                    supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
                }
                else
                {
                    message      = Strings.GetLocalizedString(198161982);
                    messageId    = new Strings.IDs?(198161982);
                    supportLevel = new SupportLevel?(SupportLevel.Transient);
                }
            }
            else if (exception is SendAsDeniedException)
            {
                message      = Strings.GetLocalizedString(2059222100);
                messageId    = new Strings.IDs?(2059222100);
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is ADTransientException)
            {
                message      = Strings.GetLocalizedString(634294555);
                messageId    = new Strings.IDs?(634294555);
                supportLevel = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is ADOperationException)
            {
                message      = Strings.GetLocalizedString(-256207770);
                messageId    = new Strings.IDs?(-256207770);
                supportLevel = new SupportLevel?(SupportLevel.Unknown);
            }
            else if (exception is DataValidationException)
            {
                message      = Strings.GetLocalizedString(-256207770);
                messageId    = new Strings.IDs?(-256207770);
                supportLevel = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is SaveConflictException || exception is OwaSaveConflictException)
            {
                message   = Strings.GetLocalizedString(-482397486);
                messageId = new Strings.IDs?(-482397486);
            }
            else if (exception is FolderSaveException)
            {
                message   = Strings.GetLocalizedString(1487149567);
                messageId = new Strings.IDs?(1487149567);
            }
            else if (exception is ObjectValidationException)
            {
                message   = Strings.GetLocalizedString(-1670564952);
                messageId = new Strings.IDs?(-1670564952);
            }
            else if (exception is CorruptDataException)
            {
                message   = Strings.GetLocalizedString(-1670564952);
                messageId = new Strings.IDs?(-1670564952);
            }
            else if (exception is Microsoft.Exchange.Data.Storage.QuotaExceededException || exception is MessageTooBigException)
            {
                message   = Strings.GetLocalizedString(-640701623);
                messageId = new Strings.IDs?(-640701623);
            }
            else if (exception is SubmissionQuotaExceededException)
            {
                message   = Strings.GetLocalizedString(178029729);
                messageId = new Strings.IDs?(178029729);
            }
            else if (exception is MessageSubmissionExceededException)
            {
                message   = Strings.GetLocalizedString(-1381793955);
                messageId = new Strings.IDs?(-1381793955);
            }
            else if (exception is AttachmentExceededException)
            {
                message   = Strings.GetLocalizedString(-2137146650);
                messageId = new Strings.IDs?(-2137146650);
            }
            else if (exception is ResourcesException || exception is NoMoreConnectionsException)
            {
                message      = Strings.GetLocalizedString(-639453714);
                messageId    = new Strings.IDs?(-639453714);
                supportLevel = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is AccountDisabledException)
            {
                message      = Strings.GetLocalizedString(531497785);
                messageId    = new Strings.IDs?(531497785);
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is AccessDeniedException)
            {
                message   = Strings.GetLocalizedString(995407892);
                messageId = new Strings.IDs?(995407892);
                AccessDeniedException ex2 = (AccessDeniedException)exception;
                if (ex2.InnerException != null)
                {
                    Exception innerException = ex2.InnerException;
                    if (innerException is MapiExceptionPasswordChangeRequired || innerException is MapiExceptionPasswordExpired)
                    {
                        message   = Strings.GetLocalizedString(540943741);
                        messageId = new Strings.IDs?(540943741);
                    }
                }
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is InvalidLicenseException)
            {
                message          = string.Format(Strings.GetLocalizedString(468041898), requestContext.UserContext.MailboxIdentity.SafeGetRenderableName());
                messageId        = new Strings.IDs?(468041898);
                messageParameter = requestContext.UserContext.MailboxIdentity.SafeGetRenderableName();
                sendWatsonReport = false;
                supportLevel     = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is TenantAccessBlockedException)
            {
                message          = Strings.GetLocalizedString(1045420842);
                messageId        = new Strings.IDs?(1045420842);
                sendWatsonReport = false;
                supportLevel     = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is PropertyErrorException)
            {
                message   = Strings.GetLocalizedString(641346049);
                messageId = new Strings.IDs?(641346049);
            }
            else if (exception is OwaInvalidOperationException)
            {
                message   = Strings.GetLocalizedString(641346049);
                messageId = new Strings.IDs?(641346049);
            }
            else if (exception is VirusDetectedException)
            {
                message   = Strings.GetLocalizedString(-589723291);
                messageId = new Strings.IDs?(-589723291);
            }
            else if (exception is VirusScanInProgressException)
            {
                message   = Strings.GetLocalizedString(-1019777596);
                messageId = new Strings.IDs?(-1019777596);
            }
            else if (exception is VirusMessageDeletedException)
            {
                message   = Strings.GetLocalizedString(1164605313);
                messageId = new Strings.IDs?(1164605313);
            }
            else if (exception is OwaExplicitLogonException)
            {
                message          = Strings.GetLocalizedString(882888134);
                messageId        = new Strings.IDs?(882888134);
                sendWatsonReport = false;
                supportLevel     = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is NoReplicaException)
            {
                message   = Strings.GetLocalizedString(1179266056);
                messageId = new Strings.IDs?(1179266056);
            }
            else if (exception is TooManyObjectsOpenedException)
            {
                message      = Strings.GetLocalizedString(-1763248954);
                messageId    = new Strings.IDs?(-1763248954);
                supportLevel = new SupportLevel?(SupportLevel.User);
            }
            else if (exception is OwaUserHasNoMailboxAndNoLicenseAssignedException)
            {
                message      = Strings.GetLocalizedString(115127791);
                messageId    = new Strings.IDs?(115127791);
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is UserHasNoMailboxException)
            {
                message          = Strings.GetLocalizedString(-765910865);
                messageId        = new Strings.IDs?(-765910865);
                messageParameter = exception.Data["PrimarySmtpAddress"].ToString();
                supportLevel     = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is StorageTransientException)
            {
                message   = Strings.GetLocalizedString(-238819799);
                messageId = new Strings.IDs?(-238819799);
                if (exception.InnerException is MapiExceptionRpcServerTooBusy)
                {
                    sendWatsonReport = false;
                    OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_ErrorMailboxServerTooBusy, string.Empty, new object[]
                    {
                        text,
                        exception.ToString()
                    });
                }
                supportLevel = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is RulesTooBigException)
            {
                message   = Strings.GetLocalizedString(-791981113);
                messageId = new Strings.IDs?(-791981113);
            }
            else if (exception is DuplicateActionException)
            {
                message   = Strings.GetLocalizedString(-555068615);
                messageId = new Strings.IDs?(-555068615);
            }
            else if (exception is ConversionFailedException && ((ConversionFailedException)exception).ConversionFailureReason == ConversionFailureReason.CorruptContent)
            {
                message   = Strings.GetLocalizedString(-1670564952);
                messageId = new Strings.IDs?(-1670564952);
            }
            else if (exception is IOException && ErrorHandlerUtilities.IsDiskFullException(exception))
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(-1729839551);
                messageId        = new Strings.IDs?(-1729839551);
                supportLevel     = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is StoragePermanentException)
            {
                message   = Strings.GetLocalizedString(861904327);
                messageId = new Strings.IDs?(861904327);
                if (exception.InnerException is MapiPermanentException)
                {
                    DiagnosticContext diagCtx = ((MapiPermanentException)exception.InnerException).DiagCtx;
                    if (diagCtx != null)
                    {
                        lids = diagCtx.ToCompactString();
                    }
                }
                supportLevel = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is TransientException)
            {
                message      = Strings.GetLocalizedString(-1729839551);
                messageId    = new Strings.IDs?(-1729839551);
                supportLevel = new SupportLevel?(SupportLevel.Transient);
                if (exception.InnerException is MapiRetryableException)
                {
                    DiagnosticContext diagCtx2 = ((MapiRetryableException)exception.InnerException).DiagCtx;
                    if (diagCtx2 != null)
                    {
                        lids = diagCtx2.ToCompactString();
                    }
                }
            }
            else if (exception is HttpException)
            {
                HttpException ex3 = (HttpException)exception;
                message          = string.Format(Strings.GetLocalizedString(1331629462), ex3.GetHttpCode());
                messageId        = new Strings.IDs?(1331629462);
                messageParameter = ex3.GetHttpCode().ToString();
            }
            else if (exception is OverBudgetException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(1856724252);
                messageId        = new Strings.IDs?(1856724252);
            }
            else if (exception is COMException || exception.InnerException is COMException)
            {
                sendWatsonReport = !ErrorHandlerUtilities.ShouldIgnoreException((exception is COMException) ? exception : exception.InnerException);
                message          = Strings.GetLocalizedString(641346049);
                messageId        = new Strings.IDs?(641346049);
                supportLevel     = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is ThreadAbortException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(641346049);
                messageId        = new Strings.IDs?(641346049);
            }
            else if (exception is FaultException || exception is InvalidSerializedAccessTokenException)
            {
                sendWatsonReport = false;
                message          = exception.Message;
            }
            else if (exception is NonExistentMailboxException)
            {
                sendWatsonReport = false;
                message          = exception.Message;
                supportLevel     = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is SlabManifestException || exception is FlightConfigurationException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(2099558169);
                messageId        = new Strings.IDs?(2099558169);
            }
            else
            {
                sendWatsonReport = true;
                message          = Strings.GetLocalizedString(641346049);
                messageId        = new Strings.IDs?(641346049);
            }
            string empty = string.Empty;

            Strings.IDs?ds          = null;
            bool        siteMailbox = false;
            bool        flag        = ErrorHandlerUtilities.RemedyExceptionHandlingError(exception, requestContext, out empty, out ds, out siteMailbox);

            if (flag)
            {
                message   = empty;
                messageId = ds;
            }
            string groupMailboxDestination = ErrorHandlerUtilities.GetGroupMailboxDestination(exception, requestContext);

            return(new ErrorInformation
            {
                Exception = exception,
                Message = message,
                MessageId = messageId,
                MessageParameter = messageParameter,
                SendWatsonReport = sendWatsonReport,
                SharePointApp = flag,
                SiteMailbox = siteMailbox,
                GroupMailboxDestination = groupMailboxDestination,
                Lids = lids,
                SupportLevel = supportLevel
            });
        }
        // Token: 0x0600097E RID: 2430 RVA: 0x00020CF4 File Offset: 0x0001EEF4
        internal static void HandleException(RequestContext requestContext, Exception exception)
        {
            if (exception is HttpException && (exception.InnerException is SlabManifestException || exception.InnerException is FlightConfigurationException))
            {
                exception = exception.InnerException;
            }
            ErrorHandlerUtilities.RecordException(requestContext, exception);
            ExTraceGlobals.CoreTracer.TraceDebug <Type, Exception>(0L, "Exception: Type: {0} Error: {1}.", exception.GetType(), exception);
            HttpContext httpContext = requestContext.HttpContext;

            HttpUtilities.MakePageNoCacheNoStore(httpContext.Response);
            if (exception is HttpException)
            {
                HttpUtilities.EndResponse(httpContext, HttpStatusCode.BadRequest);
                return;
            }
            if (exception is OwaInvalidRequestException || exception is OwaInvalidIdFormatException)
            {
                HttpUtilities.EndResponse(httpContext, HttpStatusCode.BadRequest);
                return;
            }
            if (exception is MailboxInSiteFailoverException && requestContext.UserContext != null)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "User {0}'s mailbox in-site failover occurs.", requestContext.UserContext.ExchangePrincipal.LegacyDn);
                if (requestContext.UserContext != null)
                {
                    requestContext.UserContext.DisconnectMailboxSession();
                }
            }
            if (exception is MailboxCrossSiteFailoverException || exception is WrongServerException)
            {
                if (requestContext.UserContext != null)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "User {0}'s mailbox cross-site failover occurs.", requestContext.UserContext.ExchangePrincipal.LegacyDn);
                }
                UserContextCookie userContextCookie = UserContextCookie.GetUserContextCookie(httpContext);
                if (userContextCookie != null)
                {
                    HttpUtilities.DeleteCookie(httpContext.Response, userContextCookie.CookieName);
                }
            }
            if (exception is OverBudgetException)
            {
                OverBudgetException ex = (OverBudgetException)exception;
                httpContext.Response.AppendToLog(string.Format("&OverBudget({0}/{1}),Owner:{2}[{3}]", new object[]
                {
                    ex.IsServiceAccountBudget ? "ServiceAccount" : "Normal",
                    ex.PolicyPart,
                    ex.Owner,
                    ex.Snapshot
                }));
            }
            ErrorInformation exceptionHandlingInformation = ErrorHandlerUtilities.GetExceptionHandlingInformation(exception, requestContext);

            try
            {
                if (!requestContext.ErrorSent)
                {
                    requestContext.ErrorSent = true;
                    httpContext.Response.Clear();
                    try
                    {
                        if (RequestDispatcherUtilities.GetRequestType(httpContext.Request) != OwaRequestType.ServiceRequest && RequestDispatcherUtilities.GetRequestType(httpContext.Request) != OwaRequestType.Oeh && !httpContext.Request.Path.Contains(OwaUrl.SessionDataPage.ImplicitUrl))
                        {
                            StringBuilder stringBuilder = new StringBuilder("/owa/auth/errorfe.aspx");
                            stringBuilder.Append("?");
                            stringBuilder.Append("httpCode");
                            stringBuilder.Append("=");
                            stringBuilder.Append(500);
                            if (exceptionHandlingInformation.SharePointApp)
                            {
                                stringBuilder.Append("&sharepointapp=true");
                            }
                            if (exceptionHandlingInformation.SiteMailbox)
                            {
                                stringBuilder.Append("&sm=true");
                            }
                            if (exceptionHandlingInformation.GroupMailboxDestination != null)
                            {
                                stringBuilder.Append("&gm=");
                                stringBuilder.Append(HttpUtility.UrlEncode(exceptionHandlingInformation.GroupMailboxDestination));
                            }
                            if (exceptionHandlingInformation.MessageId != null)
                            {
                                stringBuilder.Append("&");
                                stringBuilder.Append("msg");
                                stringBuilder.Append("=");
                                stringBuilder.Append((long)exceptionHandlingInformation.MessageId.Value);
                                if (!string.IsNullOrWhiteSpace(exceptionHandlingInformation.MessageParameter))
                                {
                                    stringBuilder.Append("&");
                                    stringBuilder.Append("msgParam");
                                    stringBuilder.Append("=");
                                    stringBuilder.Append(HttpUtility.UrlEncode(exceptionHandlingInformation.MessageParameter));
                                }
                            }
                            if (!string.IsNullOrWhiteSpace(httpContext.Response.Headers["X-OWA-Error"]))
                            {
                                stringBuilder.Append("&owaError=");
                                stringBuilder.Append(httpContext.Response.Headers["X-OWA-Error"]);
                            }
                            stringBuilder.Append("&owaVer=");
                            stringBuilder.Append(Globals.ApplicationVersion);
                            stringBuilder.Append("&be=");
                            stringBuilder.Append(Environment.MachineName);
                            stringBuilder.Append("&ts=");
                            stringBuilder.Append(DateTime.UtcNow.ToFileTimeUtc());
                            if (!string.IsNullOrWhiteSpace(exceptionHandlingInformation.Lids))
                            {
                                httpContext.Response.AppendToLog(string.Format("&lids={0}", exceptionHandlingInformation.Lids));
                            }
                            if (exceptionHandlingInformation.SupportLevel != null && exceptionHandlingInformation.SupportLevel != SupportLevel.Unknown)
                            {
                                httpContext.Response.AppendHeader("X-OWASuppLevel", exceptionHandlingInformation.SupportLevel.ToString());
                                httpContext.Response.AppendToLog(string.Format("&{0}={1}", "suplvl", exceptionHandlingInformation.SupportLevel.ToString()));
                            }
                            httpContext.Response.Redirect(stringBuilder.ToString(), false);
                        }
                        else
                        {
                            httpContext.Response.Write(exceptionHandlingInformation.Message);
                            httpContext.Response.StatusCode = 500;
                            if (exceptionHandlingInformation.MessageId != null)
                            {
                                httpContext.Response.AddHeader(WellKnownHeader.XOWAErrorMessageID, exceptionHandlingInformation.MessageId.ToString());
                            }
                            httpContext.Response.TrySkipIisCustomErrors = true;
                            httpContext.Response.Flush();
                        }
                        httpContext.ApplicationInstance.CompleteRequest();
                    }
                    catch (HttpException arg)
                    {
                        ExTraceGlobals.CoreTracer.TraceDebug <HttpException>(0L, "Failed to flush and send response to client after submitting watson and rendering error page. {0}", arg);
                    }
                }
            }
            finally
            {
                if (exceptionHandlingInformation.SendWatsonReport && Globals.SendWatsonReports)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug(0L, "Sending watson report");
                    ReportOptions options = (exception is AccessViolationException || exception is InvalidProgramException || exception is TypeInitializationException) ? ReportOptions.ReportTerminateAfterSend : ReportOptions.None;
                    ExWatson.SendReport(exception, options, null);
                }
                if (exception is AccessViolationException)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug(0L, "Shutting down OWA due to unrecoverable exception");
                    ErrorHandlerUtilities.TerminateProcess();
                }
                else if ((exception is InvalidProgramException || exception is TypeInitializationException) && Interlocked.Exchange(ref ErrorHandlerUtilities.queuedDelayedRestart, 1) == 0)
                {
                    new Thread(new ThreadStart(ErrorHandlerUtilities.DelayedRestartUponUnexecutableCode)).Start();
                }
                httpContext.Response.End();
            }
        }
 // Token: 0x0600115C RID: 4444 RVA: 0x00042A2D File Offset: 0x00040C2D
 protected override void ExecuteApplicationSpecificStart()
 {
     ErrorHandlerUtilities.RegisterForUnhandledExceptions();
     StoreSession.UseRPCContextPool = true;
     UMClientCommonBase.InitializePerformanceCounters(false);
 }