コード例 #1
0
            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);

                var message = "Script exception: {1}. Error number {0} (0x{0:X8}): {2} at line {3}, column {4}.";

                if (!string.IsNullOrEmpty(sourceLine))
                {
                    message += "Source line: '{5}'.";
                }

                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);
            }
コード例 #2
0
 int IActiveScriptSite.OnEnterScript()
 {
     LastException = null;
     return(0);
 }