Пример #1
0
            void IActiveScriptSite.OnScriptError(IActiveScriptError scriptError)
            {
                string sourceLine = null;

                try
                {
                    scriptError.GetSourceLineText(out sourceLine);
                }
                catch
                {
                }
                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;
            }
Пример #2
0
 void IActiveScriptSite.OnEnterScript()
 {
     _lastException = null;
 }