Deveel.Data.Sql.ExecutionContext.Raise C# (CSharp) Method

Raise() private method

private Raise ( string exceptionName ) : void
exceptionName string
return void
        internal void Raise(string exceptionName)
        {
            if (String.IsNullOrEmpty(exceptionName))
                throw new ArgumentNullException("exceptionName");

            AssertNotFinished();

            try {
                var statement = Statement;
                while (statement != null) {
                    if (statement is PlSqlBlockStatement) {
                        var block = (PlSqlBlockStatement) statement;
                        if (block.Handles(exceptionName)) {
                            block.FireHandler(this, exceptionName);
                            return;
                        }
                    }

                    statement = statement.Parent;
                }

                if (SystemErrorCodes.IsSystemError(exceptionName)) {
                    var errorCode = SystemErrorCodes.GetErrorCode(exceptionName);
                    throw new StatementException(errorCode, String.Format("Exception '{0}' explicitly risen from code", exceptionName));
                }

                var declared = Request.Context.FindDeclaredException(exceptionName);
                if (declared == null)
                    throw new InvalidOperationException(String.Format("Exception '{0}' was not declared in the context.", exceptionName));

                throw new StatementException(declared.ErrorCode,
                    String.Format("Declared exception '{0}' explicitly risen from code", exceptionName));
            } finally {
                Terminate();
            }
        }