Ejemplo n.º 1
0
        //---------------------------------------------------------------------------------------
        // HandleError
        //
        //  Handle an error. There are two actions that can be taken when an error occurs:
        //    - throwing an exception with no recovering action (eval case)
        //    - notify the host that an error occurred and let the host decide whether or not
        //      parsing has to continue (the host returns true when parsing has to continue)
        //---------------------------------------------------------------------------------------

        internal void HandleError(JScriptException error)
        {
            if (m_parser != null)
            {
                if (!m_parser.OnCompilerError(error))
                {
                    throw new EndOfFileException(); // this exception terminates the parser
                }
            }
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------------------------
        // HandleError
        //
        //  Handle an error. There are two actions that can be taken when an error occurs:
        //    - throwing an exception with no recovering action (eval case)
        //    - notify the host that an error occurred and let the host decide whether or not
        //      parsing has to continue (the host returns true when parsing has to continue)
        //---------------------------------------------------------------------------------------

        internal void HandleError(JScriptException error)
        {
            if (m_parser != null)
            {
                if (!m_parser.OnCompilerError(error))
                {
                    throw new EndOfFileException(); // this exception terminates the parser
                }
            }
        }
Ejemplo n.º 3
0
        internal void HandleError(JSError errorId, bool forceToError)
        {
            if ((errorId != JSError.UndeclaredVariable && errorId != JSError.UndeclaredFunction) || !Document.HasAlreadySeenErrorFor(Code))
            {
                var error = new JScriptException(errorId, this);

                if (forceToError)
                {
                    error.IsError = true;
                }
                else
                {
                    error.IsError = error.Severity < 2;
                }

                Document.HandleError(error);
            }
        }
Ejemplo n.º 4
0
 public JScriptExceptionEventArgs(JScriptException exception, ContextError error)
 {
     Error = error;
     Exception = exception;
 }
Ejemplo n.º 5
0
        internal void HandleError(JSError errorId, bool forceToError)
        {
            if ((errorId != JSError.UndeclaredVariable && errorId != JSError.UndeclaredFunction) || !Document.HasAlreadySeenErrorFor(Code))
            {
                var error = new JScriptException(errorId, this);

                if (forceToError)
                {
                    error.IsError = true;
                }
                else
                {
                    error.IsError = error.Severity < 2;
                }

                Document.HandleError(error);
            }
        }
Ejemplo n.º 6
0
 public JScriptExceptionEventArgs(JScriptException exception, ContextError error)
 {
     Error     = error;
     Exception = exception;
 }
Ejemplo n.º 7
0
        internal bool OnCompilerError(JScriptException se)
        {
            if (CompilerError != null && !m_settings.IgnoreAllErrors)
            {
                // format the error code
                string errorCode = "JS{0}".FormatInvariant((int)se.ErrorCode);
                if (m_settings != null && !m_settings.IgnoreErrorCollection.Contains(errorCode))
                {
                    // get the offending context
                    string context = se.ErrorSegment;

                    // if the context is empty, use the whole line
                    if (!context.IsNullOrWhiteSpace())
                    {
                        context = ": " + context;
                    }

                    CompilerError(this, new JScriptExceptionEventArgs(se, new ContextError(
                        se.IsError,
                        se.Severity,
                        GetSeverityString(se.Severity),
                        errorCode,
                        se.HelpLink,
                        se.FileContext,
                        se.Line,
                        se.Column,
                        se.EndLine,
                        se.EndColumn,
                        se.Message + context)));
                }
            }

            //true means carry on with compilation.
            return se.CanRecover;
        }