void PrintException(Exception ex) { if (ex is EcmaScriptRuntimeException) { EcmaScriptRuntimeException e = (EcmaScriptRuntimeException)ex; Console.Error.WriteLine("js: " + e.Message); if (e.ScriptStackTrace != string.Empty) { Console.Error.WriteLine(e.ScriptStackTrace); } } else if (ex is EcmaScriptThrow) { EcmaScriptThrow e = (EcmaScriptThrow)ex; Console.Error.WriteLine("js: \"{0}\", line {1}: exception from uncaught throw: {2}", e.SourceName, e.LineNumber, e.Value); } else if (ex is EcmaScriptError) { EcmaScriptError e = (EcmaScriptError)ex; Console.Error.WriteLine("js: " + e.Message); Console.Error.WriteLine(e.ScriptStackTrace); } else { Console.Error.WriteLine(ex.ToString()); } }
public virtual EcmaScriptRuntimeException RuntimeError(string message, string sourceName, int line, string lineSource, int lineOffset) { EcmaScriptException exception = new EcmaScriptRuntimeException(string.Format("EcmaScriptRuntimeException :: {0}", message), sourceName, line, lineSource == null ? string.Empty : lineSource.Trim(), lineOffset); exception.Source = "EcmaScriptRuntime"; throw exception; }
public virtual void Error(string message, string sourceName, int line, string lineSource, int lineOffset) { EcmaScriptException exception = new EcmaScriptRuntimeException(message, sourceName, line, lineSource == null ? string.Empty : lineSource.Trim(), lineOffset); exception.Source = "EcmaScript"; throw exception; }