private void OnCompilerError(object sender, JScriptExceptionEventArgs e) { JScriptException error = e.Exception; // ignore severity values greater than our severity level if (error.Severity <= m_warningLevel) { // we found an error m_errorsFound = true; // get the offending line string line = error.LineText; // get the offending context string context = error.ErrorSegment; // if the context is empty, use the whole line if (context.Length == 0) { context = line; } // the error code is the lower half of the error number, in decimal, prepended with "JS" // again, NOT LOCALIZABLE so the format is not in the resources string code = string.Format( CultureInfo.InvariantCulture, "JS{0}", (error.Error & (0xffff)) ); // the location is the file name followed by the line and start/end columns within parens. // if the file context is empty, use "stdin" as the file name. // this string is NOT LOCALIZABLE, so not putting the format in the resources string location = string.Format( CultureInfo.InvariantCulture, "{0}({1},{2}-{3})", (string.IsNullOrEmpty(error.FileContext) ? "stdin" : error.FileContext), error.Line, error.StartColumn, error.EndColumn ); WriteError(CreateBuildError( location, GetSeverityString(error.Severity), (error.Severity < 2), // severity 0 and 1 are errors; rest are warnings code, error.Message + ": " + context // message, colon, context (which may be the entire line) )); // Error;;{0}: {1} //WriteError(StringMgr.GetString("ErrorLine1", GetSeverityString(error.Severity), error.Message)); // ;;At line {0}, col {1}-{2}: {3} //WriteError(StringMgr.GetString("ErrorLine2", error.Line, error.StartColumn, error.EndColumn, context)); WriteError(string.Empty); } }
//--------------------------------------------------------------------------------------- // 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 } } }
//--------------------------------------------------------------------------------------- // 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 } } }
private void OnJavaScriptError(object sender, JScriptExceptionEventArgs e) { JScriptException error = e.Exception; // ignore severity values greater than our severity level if (error.Severity <= WarningLevel) { // get the offending line string line = error.LineText; // get the offending context string context = error.ErrorSegment; // if the context is empty, use the whole line if (context.Length == 0) { context = line; } // the error code is the lower half of the error number, in decimal, prepended with "JS" // again, NOT LOCALIZABLE so the format is not in the resources string code = string.Format( CultureInfo.InvariantCulture, "JS{0}", error.Error & 0xffff); // the location is the file name followed by the line and start/end columns within parens. // if the file context is empty, use "stdin" as the file name. // this string is NOT LOCALIZABLE, so not putting the format in the resources string location = string.Format( CultureInfo.InvariantCulture, "{0}({1},{2}-{3})", string.IsNullOrEmpty(FileName) ? "MinifyJavaScript" : FileName, error.Line, error.StartColumn, error.EndColumn); AddErrorMessage( location, // not localized string.Empty, // localizable, optional error.Severity < 2, // NOT localized, only two options code, // not localized, cannot contain spaces error.Message + ": " + context); // localizable with optional arguments } }
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); } }
internal void HandleError(JSError errorId, String message, bool treatAsError) { if ((errorId == JSError.UndeclaredVariable || errorId == JSError.UndeclaredFunction) && Document.HasAlreadySeenErrorFor(Code)) { return; } JScriptException error = new JScriptException(errorId, this); if (message != null) { error.Value = message; } if (treatAsError) { error.IsError = treatAsError; } int sev = error.Severity; if (sev < m_errorReported) { Document.HandleError(error); m_errorReported = sev; } }
public JScriptExceptionEventArgs(JScriptException exception) { m_exception = exception; }
internal bool OnCompilerError(JScriptException se) { if (CompilerError != null) { // get the offending line string line = se.LineText; // get the offending context string context = se.ErrorSegment; // if the context is empty, use the whole line if (string.IsNullOrEmpty(context)) { context = line; } CompilerError(this, new JScriptExceptionEventArgs(se, new ContextError( se.IsError, se.Severity, GetSeverityString(se.Severity), string.Format(CultureInfo.InvariantCulture, "JS{0}", (se.Error & (0xffff))), se.HelpLink, se.FileContext, se.Line, se.Column, se.EndLine, se.EndColumn, se.Message + ": " + context))); } //true means carry on with compilation. return se.CanRecover; }
internal void HandleError(JSError errorId, String message, bool treatAsError) { if ((errorId == JSError.UndeclaredVariable || errorId == JSError.UndeclaredFunction) && Document.HasAlreadySeenErrorFor(Code)) return; JScriptException error = new JScriptException(errorId, this); if (message != null) error.Value = message; if (treatAsError) error.IsError = treatAsError; int sev = error.Severity; if (sev < m_errorReported) { Document.HandleError(error); m_errorReported = sev; } }
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); } }
public JScriptExceptionEventArgs(JScriptException exception, ContextError error) { Error = error; Exception = exception; }