예제 #1
0
        public static string GetDiagnosticContextFromException(Exception exception)
        {
            string result = string.Empty;

            for (Exception ex = exception; ex != null; ex = ex.InnerException)
            {
                DiagnosticContext      diagnosticContext = null;
                MapiPermanentException ex2 = ex as MapiPermanentException;
                MapiRetryableException ex3 = ex as MapiRetryableException;
                if (ex2 != null)
                {
                    diagnosticContext = ex2.DiagCtx;
                }
                else if (ex3 != null)
                {
                    diagnosticContext = ex3.DiagCtx;
                }
                if (diagnosticContext != null)
                {
                    result = string.Format("[e::{0}]", diagnosticContext.ToCompactString());
                    break;
                }
            }
            return(result);
        }
        // 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
            });
        }