Deveel.Data.SystemErrorCodes.IsSystemError C# (CSharp) Method

IsSystemError() public static method

public static IsSystemError ( int value ) : bool
value int
return bool
        public static bool IsSystemError(int value)
        {
            return ErrorNameMap.Values.Any(x => x == value);
        }

Same methods

SystemErrorCodes::IsSystemError ( string name ) : bool

Usage Example

Ejemplo n.º 1
0
        public static void DeclareException(this IContext context, int errorCode, string exceptionName)
        {
            if (SystemErrorCodes.IsSystemError(errorCode))
            {
                throw new ArgumentException(String.Format("The code '{0}' is reserved for system", errorCode));
            }
            if (SystemErrorCodes.IsSystemError(exceptionName))
            {
                throw new ArgumentException(String.Format("The exception name '{0}' is reserved for system", exceptionName));
            }

            var currentContext = context;

            while (currentContext != null)
            {
                if (currentContext is IExceptionInitScope)
                {
                    var scope = (IExceptionInitScope)currentContext;
                    scope.DeclareException(errorCode, exceptionName);
                    return;
                }

                currentContext = currentContext.Parent;
            }

            throw new InvalidOperationException("Unable to declare the exception.");
        }