protected override void Render(HtmlTextWriter writer) { if (_exception != null) { if (SPContext.Current.Web.UserIsSiteAdmin && engine.IronRuntime.IronHive.Web.CurrentUser.IsSiteAdmin) { var eo = engine.ScriptEngine.GetService <ExceptionOperations>(); string error = eo.FormatException(_exception); IronRuntime.LogError(String.Format("Error executing script {0}: {1}", ScriptName, error), _exception); if (engine != null) { new IronLogger(engine.IronRuntime).Log(String.Format("Ruby Error: {0} at {1}", _exception.Message, error)); } writer.Write(error); } else { writer.Write("Error occured."); } } try { ctrl.RenderControl(writer); } catch (Exception ex) { IronDiagnosticsService.Local.WriteTrace(1, IronDiagnosticsService.Local[IronCategoryDiagnosticsId.Controls], TraceSeverity.Unexpected, String.Format("Error: {0}; Stack: {1}", ex.Message, ex.StackTrace)); writer.Write(ex.Message); } }
public override object EvaluateExpression(object target, System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context) { string value = String.Empty; string scriptName = entry.Expression; try { string functionName = null; if (scriptName.Contains("@")) { var tmp = scriptName.Split('@'); functionName = tmp[0].Trim(); scriptName = tmp[1].Trim(); } else { throw new ArgumentException("Invalid expression! Use <%$Iron:My.sayHello@my/functions.rb"); } engine = IronRuntime.GetDefaultIronRuntime(SPContext.Current.Site).GetEngineByExtension(Path.GetExtension(scriptName)); value = engine.InvokeDynamicFunction(functionName, scriptName, target, entry).ToString(); } catch (Exception ex) { IronRuntime.LogError("Error", ex); if (SPContext.Current.Web.UserIsSiteAdmin && engine.IronRuntime.IronHive.Web.CurrentUser.IsSiteAdmin) { var eo = engine.ScriptEngine.GetService <ExceptionOperations>(); string error = eo.FormatException(ex); IronRuntime.LogError(String.Format("Error executing script {0}: {1}", scriptName, error), ex); value = error; if (engine != null) { new IronLogger(engine.IronRuntime).Log(String.Format("Ruby Error: {0} at {1}", ex.Message, error)); } } else { value = "Error occured"; } } return(value); }
protected override void Render(HtmlTextWriter writer) { if (Exception != null) { if (SPContext.Current.Web.UserIsSiteAdmin && engine.IronRuntime.IronHive.Web.CurrentUser.IsSiteAdmin) { var eo = engine.ScriptEngine.GetService <ExceptionOperations>(); string error = eo.FormatException(Exception); IronRuntime.LogError(String.Format("Error executing script {0}: {1}", ScriptName, error), Exception); if (engine != null) { new IronLogger(engine.IronRuntime).Log(String.Format("Ruby Error: {0} at {1}", Exception.Message, error)); } writer.Write(error); } else { writer.Write("Error occured."); } } else { try { ctrl.RenderControl(writer); } catch (Exception ex) { writer.Write(ex.Message); IronRuntime.LogError("Error", ex); } } }