本文整理汇总了C#中DataType.ToErrorTypeString方法的典型用法代码示例。如果您正苦于以下问题:C# DataType.ToErrorTypeString方法的具体用法?C# DataType.ToErrorTypeString怎么用?C# DataType.ToErrorTypeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataType
的用法示例。
在下文中一共展示了DataType.ToErrorTypeString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BadArgumentNoValue
/// <summary>
/// Creates a ScriptRuntimeException with a predefined error message specifying that
/// a function was called with no value when a value was required.
///
/// This function creates a message like "bad argument #xxx to 'yyy' (zzz expected, got no value)"
/// while <see cref="BadArgumentValueExpected" /> creates a message like "bad argument #xxx to 'yyy' (value expected)"
/// </summary>
/// <param name="argNum">The argument number (0-based).</param>
/// <param name="funcName">Name of the function generating this error.</param>
/// <param name="expected">The expected data type.</param>
/// <returns>
/// The exception to be raised.
/// </returns>
public static ScriptRuntimeException BadArgumentNoValue(int argNum, string funcName, DataType expected)
{
return new ScriptRuntimeException("bad argument #{0} to '{1}' ({2} expected, got no value)",
argNum + 1, funcName, expected.ToErrorTypeString());
}
示例2: AttemptToCallNonFunc
/// <summary>
/// Creates a ScriptRuntimeException with a predefined error message specifying that
/// an attempt to call a non-function was made
/// </summary>
/// <param name="type">The lua non-function data type.</param>
/// <param name="debugText">The debug text to aid location (appears as "near 'xxx'").</param>
/// <returns></returns>
public static ScriptRuntimeException AttemptToCallNonFunc(DataType type, string debugText = null)
{
string functype = type.ToErrorTypeString();
if (debugText != null)
return new ScriptRuntimeException("attempt to call a {0} value near '{1}'", functype, debugText);
else
return new ScriptRuntimeException("attempt to call a {0} value", functype);
}
示例3: BadArgument
/// <summary>
/// Creates a ScriptRuntimeException with a predefined error message specifying that
/// a function was called with a bad argument
/// </summary>
/// <param name="argNum">The argument number (0-based).</param>
/// <param name="funcName">Name of the function generating this error.</param>
/// <param name="expected">The expected data type.</param>
/// <param name="got">The data type received.</param>
/// <param name="allowNil">True if nils were allowed in this call.</param>
/// <returns>
/// The exception to be raised.
/// </returns>
public static ScriptRuntimeException BadArgument(int argNum, string funcName, DataType expected, DataType got, bool allowNil)
{
return BadArgument(argNum, funcName, expected.ToErrorTypeString(), got.ToErrorTypeString(), allowNil);
}