private string GetMessage(Exception baseException)
        {
            if (baseException is NpgsqlException)
            {
                ExceptionKey exceptionKey = (ExceptionKey)(baseException as NpgsqlException).ErrorCode;

                switch (exceptionKey)
                {
                case ExceptionKey.TimeoutExpired:
                    return(Constant.Exception_sql_TimeoutExpired);

                case ExceptionKey.HasForeignKey:
                    return(Constant.Exception_sql_HasDepandantInfo);

                case ExceptionKey.HasDuplicateInfo:
                    return(Constant.Exception_sql_HasDuplicateInfo);

                case ExceptionKey.KeyAlreadyExsits:
                    return(Constant.Exception_sql_KeyAlreadyExsits);

                case ExceptionKey.ArithmeticOverflow:
                    return(Constant.Exception_sql_ArithmeticOverflow);

                default:
                    return(Constant.Exception_HasError);
                }
            }
            return(Constant.Exception_HasError);
        }
        private string GetMessage(ExceptionKey exceptionKey)
        {
            switch (exceptionKey)
            {
            case ExceptionKey.AuthenticationFailed:
                return(Constant.Exception_AuthenticationFailed);

            case ExceptionKey.NotDefined:
            default:
                return(Constant.Exception_HasError);
            }
        }
        private string GetMessage(ExceptionKey exceptionKey)
        {
            switch (exceptionKey)
            {
            case ExceptionKey.NoActiveTransaction:
                return(Constant.Exception_NoActiveTransaction);

            case ExceptionKey.SendEmailProblem:
                return(Constant.Exception_SendEmailProblem);

            case ExceptionKey.SignUpFailed:
                return(Constant.Exception_SignUpFailed);

            case ExceptionKey.LoginFailed:
                return(Constant.Exception_LoginFailed);

            case ExceptionKey.AuthenticationFailed:
                return(Constant.Exception_AuthenticationFailed);

            case ExceptionKey.ChangePasswordFailed:
                return(Constant.Exception_ChangePasswordFailed);

            case ExceptionKey.RoleCreationFailed:
                return(Constant.Exception_RoleCreationFailed);

            case ExceptionKey.EmailAlreadyExist:
                return(Constant.Exception_EmailAlreadyExist);

            case ExceptionKey.UserNotAccess:
                return(Constant.Exception_UserNotAccess);

            case ExceptionKey.LoginNeeded:
                return(Constant.Exception_LoginNeeded);

            case ExceptionKey.NotDefined:
            default:
                return(Constant.Exception_HasError);
            }
        }
Beispiel #4
0
        public static string GetString(this ExceptionKey p)
        {
            switch (p)
            {
            case ExceptionKey.ERROR_GET:
                return("ERROR_GET");

            case ExceptionKey.ERROR_CREATE:
                return("ERROR_CREATE");

            case ExceptionKey.ERROR_UPDATE:
                return("ERROR_UPDATE");

            case ExceptionKey.ERROR_DELETE:
                return("ERROR_DELETE");

            case ExceptionKey.ERROR_IN_USE:
                return("ERROR_IN_USE");

            default:
                return("ERROR_GET");
            }
        }
 public CustomException(ExceptionKey exceptionKey, params object[] args) =>
 this.CustomMessage = string.Format(GetMessage(exceptionKey), args);
Beispiel #6
0
 public CustomException(ExceptionKey exceptionKey, params object[] args)
 {
     this.ExceptionKey = exceptionKey;
     this.Message      = string.Format(GetMessage(), args);
 }
 public virtual string ToAsErrorMessage(ExceptionKey code = ExceptionKey.None, string message = null)
 {
     return(ToAsErrorMessage(code == ExceptionKey.None ? null : code.ToString(), message));
 }
 public virtual string GetException(ExceptionKey code)
 {
     return(GetException(code.ToString()));
 }
 public static string ToAsErrorMessage(ExceptionKey code = ExceptionKey.None, string message = null)
 {
     return(Adapter.ToAsErrorMessage(code, message));
 }
 public static string GetException(ExceptionKey code)
 {
     return(Adapter.GetException(code));
 }