private string GetTrace(Statement lastStatement, JavaScriptException v) { string trace = v.GetTrace(); trace = _engine.GetTrace(lastStatement, trace); return(trace); }
private Client.Exceptions.Documents.Patching.JavaScriptException CreateFullError(DocumentsOperationContext ctx, JavaScriptException e) { string msg; if (e.Error.IsString()) { msg = e.Error.AsString(); } else if (e.Error.IsObject()) { msg = JsBlittableBridge.Translate(ctx, ScriptEngine, e.Error.AsObject()).ToString(); } else { msg = e.Error.ToString(); } msg = "At " + e.Column + ":" + e.LineNumber + Environment.NewLine + msg; var javaScriptException = new Client.Exceptions.Documents.Patching.JavaScriptException(msg, e); return(javaScriptException); }
/// <summary> /// http://www.ecma-international.org/ecma-262/5.1/#sec-13.2.1 /// </summary> /// <param name="thisArg"></param> /// <param name="arguments"></param> /// <returns></returns> public override JsValue Call(JsValue thisArg, JsValue[] arguments) { using (new StrictModeScope(Strict, true)) { // setup new execution context http://www.ecma-international.org/ecma-262/5.1/#sec-10.4.3 JsValue thisBinding; if (StrictModeScope.IsStrictModeCode) { thisBinding = thisArg; } else if (thisArg == Undefined.Instance || thisArg == Null.Instance) { thisBinding = Engine.Global; } else if (!thisArg.IsObject()) { thisBinding = TypeConverter.ToObject(Engine, thisArg); } else { thisBinding = thisArg; } var localEnv = LexicalEnvironment.NewDeclarativeEnvironment(Engine, Scope); Engine.EnterExecutionContext(localEnv, localEnv, thisBinding); try { Engine.DeclarationBindingInstantiation( DeclarationBindingType.FunctionCode, _functionDeclaration.FunctionDeclarations, _functionDeclaration.VariableDeclarations, this, arguments); var result = Engine.ExecuteStatement(_functionDeclaration.Body); if (result.Type == Completion.Throw) { JavaScriptException ex = new JavaScriptException(result.GetValueOrDefault()); ex.Location = result.Location; throw ex; } if (result.Type == Completion.Return) { return result.GetValueOrDefault(); } } finally { Engine.LeaveExecutionContext(); } return Undefined.Instance; } }
public JavaScriptException(JavaScriptException exception) : base(exception.Message) { Error = exception.Error; Location = exception.Location; }
public JavaScriptException(JavaScriptException exception, Exception?innerException) : base(exception.Message, exception.InnerException) { Error = exception.Error; Location = exception.Location; }
public JavaScriptException(Statement stmt, string message, JavaScriptException ex) : base(message + ": " + stmt.ToString(), ex) { _errorObject = new JsValue(message + ": " + stmt); }