AuthoringSink::AddError Method (String^, String^, TextSpan, Severity)
Adds an error in parsing message for later reporting.
Assembly: Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)
public: virtual void AddError( String^ path, String^ message, TextSpan context, Severity sev )
Parameters
- path
-
Type:
System::String^
[in] The source file's path.
- message
-
Type:
System::String^
[in] The error message to report.
- context
-
Type:
Microsoft.VisualStudio.TextManager.Interop::TextSpan
[in] A TextSpan indicating what triggered the error (this is used to mark the bad code).
- sev
-
Type:
Microsoft.VisualStudio.Package::Severity
[in] The severity of the error: a value from the Severity enumeration.
If the parser encounters any errors in the parsing operation, it can store the errors for later reporting through this method. The assumption here is the parser can recover from simple syntax errors and continue on parsing. This allows the user to see all the errors encountered and fix them all before committing to a compilation.
Note that this approach to storing errors is used in support of checking the source code dynamically, before the user actually compiles the code. All the errors in the list are shown in the code (typically with the squiggly underline) and the error message is shown when the user holds the cursor over the error line.