/// <summary> /// Initialize /// </summary> /// <param name="errorType">Type of the error. "Syntax Error"</param> /// <param name="error">Error message</param> /// <param name="scriptpath">Path of the script</param> /// <param name="lineNumber">Line number of the error.</param> /// <param name="charPos">The char position of the error.</param> public LangException(string errorType, string error, string scriptpath, int lineNumber, int charPos = 0) : base(error) { Error = new ScriptError(); Error.Line = lineNumber; Error.Message = error; Error.ErrorType = errorType; Error.File = scriptpath; Error.Column = charPos; }
/// <summary> /// Loads the arguments supplied into the runtime. /// </summary> /// <param name="args">The metadata of the arguments.</param> /// <param name="argValues">The argument values as strings</param> public RunResult LoadArguments(List<ArgAttribute> args, List<string> argValues) { var errors = new List<ScriptError>(); var start = DateTime.Now; for(var ndx = 0; ndx < args.Count; ndx++) { var arg = args[ndx]; var argVal = argValues[ndx]; try { var langType = LangTypeHelper.ConvertToLangTypeFromLangTypeName(arg.Type); var langValueText = argVal; if (string.IsNullOrEmpty(argVal) && !arg.Required && arg.DefaultValue != null) langValueText = Convert.ToString(arg.DefaultValue); var langValue = LangTypeHelper.ConvertToLangValue(langType, langValueText); this.Context.Memory.SetValue(arg.Name, langValue, false); this.Context.Symbols.DefineVariable(arg.Name, langType); } catch (Exception) { var error = new ScriptError(); error.Message = "Unable to create variable : " + arg.Name + " with value : " + argVal; errors.Add(error); throw; } } var end = DateTime.Now; var result = new RunResult(start, end, errors.Count == 0, errors); return result; }
/// <summary> /// Add the specified error and source position of the expression /// </summary> /// <param name="errorCode">The distinct error code.</param> /// <param name="errorText">Error text</param> /// <param name="node">The expression associated with the warning</param> /// <param name="errorType">Type of error.</param> private void AddSemanticError(string errorCode, string errorText, AstNode node, ScriptErrorType errorType) { string errormsg = errorText + " at line : " + node.Ref.Line + ", pos : " + node.Ref.CharPos; var error = new ScriptError(); error.Line = node.Ref.Line; error.File = node.Ref.ScriptName; error.Column = node.Ref.CharPos; error.ErrorType = errorType.ToString(); error.ErrorCode = errorCode; error.Message = errormsg; _errors.Add(error); }