private static PageResult GetCodePageResult(ScriptContext context, string code, Dictionary <string, object> args) { context.AssertCode(); PageResult pageResult = null; try { var page = context.CodeSharpPage(code); pageResult = new PageResult(page); args.Each((x, y) => pageResult.Args[x] = y); return(pageResult); } catch (Exception e) { if (ScriptContextUtils.ShouldRethrow(e)) { throw; } throw ScriptContextUtils.HandleException(e, pageResult ?? new PageResult(context.EmptyPage)); } }