int IActiveScriptSite.OnScriptError(IActiveScriptError scriptError) { string sourceLine = null; try { scriptError.GetSourceLineText(out sourceLine); } catch { // happens sometimes... } uint sourceContext; int lineNumber; int characterPosition; scriptError.GetSourcePosition(out sourceContext, out lineNumber, out characterPosition); lineNumber++; characterPosition++; System.Runtime.InteropServices.ComTypes.EXCEPINFO exceptionInfo; scriptError.GetExceptionInfo(out exceptionInfo); string message; if (!string.IsNullOrEmpty(sourceLine)) { message = "Script exception: {1}. Error number {0} (0x{0:X8}): {2} at line {3}, column {4}. Source line: '{5}'."; } else { message = "Script exception: {1}. Error number {0} (0x{0:X8}): {2} at line {3}, column {4}."; } _LastException = new ScriptException(string.Format(message, exceptionInfo.scode, exceptionInfo.bstrSource, exceptionInfo.bstrDescription, lineNumber, characterPosition, sourceLine)); _LastException.Column = characterPosition; _LastException.Description = exceptionInfo.bstrDescription; _LastException.Line = lineNumber; _LastException.Number = exceptionInfo.scode; _LastException.Text = sourceLine; return(0); }
int IActiveScriptSite.OnEnterScript() { _LastException = null; return(0); }