예제 #1
0
 private void ThrowExceptionIfFaulty()
 {
     if (IsFaulty)
     {
         throw new CoreBaseException(ResourceErrors.GetStringCacheIsFaulty());
     }
 }
        private IEnumerable <string> GetErrorMessages(Exception ex)
        {
            if (ex is HostBasePartLdapJobLoginException)
            {
                return(new[]
                {
                    ResourceErrors.GetStringFailedToLogin()
                });
            }

            return(null);
        }
        private IEnumerable <string> GetErrorMessages(Exception ex)
        {
            if (ex is HostBasePartAuthJobCurrentUserGetException)
            {
                return(new[]
                {
                    ResourceErrors.GetStringFailedToGetCurrentUser()
                });
            }

            return(null);
        }
        private IEnumerable <string> GetErrorMessages(Exception ex)
        {
            if (ex is HostBasePartAuthJobUserEntityCreateException)
            {
                return(new[]
                {
                    ResourceErrors.GetStringFailedToCreateUser()
                });
            }

            return(null);
        }
        private IEnumerable <string> GetErrorMessages(Exception ex)
        {
            var result = new List <string>();

            var errorMessages = GetErrorMessagesOnInvalidInput(ex);

            if (errorMessages != null)
            {
                result.AddRange(errorMessages);
            }

            if (ex is ModAuthBaseJobRegisterException)
            {
                result.Add(ResourceErrors.GetStringUserRegistrationIsFailed());
            }

            return(result.Any() ? result : null);
        }
        /// <summary>
        /// Получить сообщения об ошибках.
        /// </summary>
        /// <param name="ex">Исключение.</param>
        /// <returns>Сообщения.</returns>
        protected virtual IEnumerable <string> GetErrorMessages(Exception ex)
        {
            var msg = ex.ToString();

            var setting = DataBaseSettings.DummyMain;

            if (msg.Contains(setting.DbUniqueIndexForName))
            {
                return(new[]
                {
                    string.Format(
                        ResourceErrors.GetStringFormatFieldValueIsNotUnique(),
                        "Name"
                        )
                });
            }

            return(null);
        }
        private IEnumerable <string> GetErrorMessages(Exception ex)
        {
            var result = new List <string>();

            var errorMessages = GetErrorMessagesOnInvalidInput(ex);

            if (errorMessages != null)
            {
                result.AddRange(errorMessages);
            }

            if (ex is ModIdentityServerBaseExceptionLogin)
            {
                result.Add(ResourceErrors.GetStringUserLoginIsFailed());
            }
            else if (ex is ModIdentityServerBaseExceptionInvalidReturnUrl)
            {
                result.Add(ResourceErrors.GetStringReturnUrlIsInvalid());
            }

            return(result.Any() ? result : null);
        }