We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

TextTransformation.Error Method

Creates a new error to store information about errors that occur during the text template transformation process.

Namespace:  Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating (in Microsoft.VisualStudio.TextTemplating.dll)

public void Error(
	string message


Type: System.String

A message that describes the error.

Adds the error to the collection of Errors for the text template transformation process. Sets the line number of the error to -1, and the column number of the error to -1 by default.

The following code example demonstrates calling the Error method from a text template. Paste this code into any text template file and run the text template transformation to see the results. The error will appear in the Error List.

    string firstName = null;

        //raise an error, this will appear in the error list
        Error("I have no name.");