MsieJavaScriptEngine.ActiveScript.ActiveScriptException.Create C# (CSharp) Method

Create() static private method

static private Create ( IActiveScriptError error ) : ActiveScriptException
error IActiveScriptError
return ActiveScriptException
        internal static ActiveScriptException Create(IActiveScriptError error)
        {
            string message = string.Empty;
            int errorCode = 0;
            short errorWCode = 0;
            uint sourceContext = 0;
            string subcategory = string.Empty;
            string helpLink = string.Empty;
            uint lineNumber = 0;
            int columnNumber = 0;
            string sourceError = string.Empty;

            try
            {
                error.GetSourceLineText(out sourceError);
            }
            catch
            {
                // Do nothing
            }

            try
            {
                error.GetSourcePosition(out sourceContext, out lineNumber, out columnNumber);
                ++lineNumber;
                ++columnNumber;
            }
            catch
            {
                // Do nothing
            }

            try
            {
                EXCEPINFO excepInfo;
                error.GetExceptionInfo(out excepInfo);

                message = excepInfo.bstrDescription;
                subcategory = excepInfo.bstrSource;
                errorCode = excepInfo.scode;
                errorWCode = excepInfo.wCode;
                if (!string.IsNullOrWhiteSpace(excepInfo.bstrHelpFile)
                    && excepInfo.dwHelpContext != 0)
                {
                    helpLink = string.Format("{0}: {1}", excepInfo.bstrHelpFile, excepInfo.dwHelpContext);
                }
                else if (!string.IsNullOrWhiteSpace(excepInfo.bstrHelpFile))
                {
                    helpLink = excepInfo.bstrHelpFile;
                }
            }
            catch
            {
                // Do nothing
            }

            var activeScriptException = new ActiveScriptException(message)
            {
                ErrorCode = errorCode,
                ErrorWCode = errorWCode,
                SourceContext = sourceContext,
                Subcategory = subcategory,
                LineNumber = lineNumber,
                ColumnNumber = columnNumber,
                SourceError = sourceError,
                HelpLink = helpLink,
            };

            return activeScriptException;
        }

Usage Example

            public void OnScriptErrorDebug(IActiveScriptErrorDebug errorDebug, out bool enterDebugger,
                                           out bool callOnScriptErrorWhenContinuing)
            {
                var error = errorDebug as IActiveScriptError;

                if (error != null)
                {
                    _jsEngine._lastException = ActiveScriptException.Create(GetErrorDetails(error), error);
                }

                enterDebugger = true;
                callOnScriptErrorWhenContinuing = true;
            }
All Usage Examples Of MsieJavaScriptEngine.ActiveScript.ActiveScriptException::Create