コード例 #1
0
ファイル: Environment.cs プロジェクト: weinyzhou/alphaTab
        static void PlatformInit()
        {
            RenderEngines["svg"]     = () => new FontSvgCanvas();
            RenderEngines["default"] = () => new FontSvgCanvas();
            RenderEngines["html5"]   = () => new Platform.JavaScript.Html5Canvas();
            FileLoaders["default"]   = () => new Platform.JavaScript.JsFileLoader();

            // check whether webfont is loaded
            CheckFontLoad();

            JsContext.JsCode("Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; };");

            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As <bool>())
            {
                var scriptElement = HtmlContext.document.Member("currentScript").As <HtmlScriptElement>();
                if (!scriptElement.As <bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As <bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As <bool>())
                        {
                            scriptElement =
                                HtmlContext.document.querySelector("script[data-alphatab]").As <HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As <bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaTab script file for worker, please add the data-alphatab attribute to the script tag that includes alphaTab or provide it when initializing alphaTab");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }
コード例 #2
0
            private static Exception ParseResponseException(JavascriptResponse response)
            {
                var jsErrorJSON = response.Message;

                // try parse js exception
                jsErrorJSON = jsErrorJSON.Substring(Math.Max(0, jsErrorJSON.IndexOf("{")));
                jsErrorJSON = jsErrorJSON.Substring(0, jsErrorJSON.LastIndexOf("}") + 1);

                if (!string.IsNullOrEmpty(jsErrorJSON))
                {
                    JsError jsError = null;
                    try {
                        jsError = DeserializeJSON <JsError>(jsErrorJSON);
                    } catch {
                        // ignore will throw error at the end
                    }
                    if (jsError != null)
                    {
                        jsError.Name    = jsError.Name ?? "";
                        jsError.Message = jsError.Message ?? "";
                        jsError.Stack   = jsError.Stack ?? "";
                        var jsStack = jsError.Stack.Substring(Math.Min(jsError.Stack.Length, (jsError.Name + ": " + jsError.Message).Length)).Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                        jsStack = jsStack.Select(l => l.Substring(1)).ToArray(); // "    at" -> "   at"

                        return(new JavascriptException(jsError.Name, jsError.Message, jsStack));
                    }
                }

                return(new JavascriptException("Javascript Error", response.Message, new string[0]));
            }
コード例 #3
0
 internal JsException(JsError errorNumber, JsContext context)
 {
     Value = null;
     m_context = (context == null ? null : context.Clone());
     FileContext = (context == null ? null : context.Document.FileContext);
     ErrorCode = errorNumber;
     CanRecover = true;
 }
コード例 #4
0
 internal JsException(JsError errorNumber, JsContext context)
 {
     Value       = null;
     m_context   = (context == null ? null : context.Clone());
     FileContext = (context == null ? null : context.Document.FileContext);
     ErrorCode   = errorNumber;
     CanRecover  = true;
 }
コード例 #5
0
 private JsScannerException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     m_errorId = (JsError)Enum.Parse(typeof(JsError), info.GetString("errorid"));
 }
コード例 #6
0
 private JsScannerException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     m_errorId = (JsError)Enum.Parse(typeof(JsError), info.GetString("errorid"));
 }
コード例 #7
0
            private static Exception ParseResponseException(JavascriptResponse response, IEnumerable <string> evaluatedScriptFunctions)
            {
                var jsErrorJSON = response.Message;

                // try parse js exception
                jsErrorJSON = jsErrorJSON.Substring(Math.Max(0, jsErrorJSON.IndexOf("{")));
                jsErrorJSON = jsErrorJSON.Substring(0, jsErrorJSON.LastIndexOf("}") + 1);

                var evaluatedStackFrames = evaluatedScriptFunctions.Where(f => !string.IsNullOrEmpty(f))
                                           .Select(f => new JavascriptStackFrame()
                {
                    FunctionName = f, SourceName = "eval"
                });

                if (!string.IsNullOrEmpty(jsErrorJSON))
                {
                    JsError jsError = null;
                    try {
                        jsError = DeserializeJSON <JsError>(jsErrorJSON);
                    } catch {
                        // ignore will throw error at the end
                    }
                    if (jsError != null)
                    {
                        jsError.Name    = jsError.Name ?? "";
                        jsError.Message = jsError.Message ?? "";
                        jsError.Stack   = jsError.Stack ?? "";
                        var jsStack = jsError.Stack.Substring(Math.Min(jsError.Stack.Length, (jsError.Name + ": " + jsError.Message).Length))
                                      .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

                        var parsedStack = new List <JavascriptStackFrame>();

                        parsedStack.AddRange(evaluatedStackFrames);

                        foreach (var stackFrame in jsStack)
                        {
                            var frameParts = StackFrameRegex.Match(stackFrame);
                            if (frameParts.Success)
                            {
                                parsedStack.Add(new JavascriptStackFrame()
                                {
                                    FunctionName = frameParts.Groups["method"].Value,
                                    SourceName   = frameParts.Groups["location"].Value,
                                    LineNumber   = int.Parse(frameParts.Groups["line"].Value),
                                    ColumnNumber = int.Parse(frameParts.Groups["column"].Value)
                                });
                            }
                        }

                        return(new JavascriptException(jsError.Name, jsError.Message, parsedStack));
                    }
                }

                return(new JavascriptException("Javascript Error", response.Message, evaluatedStackFrames));
            }
コード例 #8
0
        public virtual Exception InternalInit(JsError error)
        {
            if (stacktrace != null)
            {
                return(this);
            }

            stacktrace    = error.stack;
            toStringSaved = toString();
            return(this);
        }
コード例 #9
0
ファイル: Platform.cs プロジェクト: zwdesigns/alphaSynth
        private static void PlatformInit()
        {
            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As <bool>())
            {
                var scriptElement = HtmlContext.document.Member("currentScript").As <HtmlScriptElement>();

                if (!scriptElement.As <bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As <bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As <bool>())
                        {
                            scriptElement = HtmlContext.document.querySelector("script[data-alphasynth]").As <HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As <bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaSynth script file for worker, please add the data-alphasynth attribute to the script tag that includes alphaSynth or provide it when initializing alphaSynth");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Return the default severity for a given JSError value
        /// guide: 0 == there will be a run-time error if this code executes
        ///        1 == the programmer probably did not intend to do this
        ///        2 == this can lead to cross-browser of future problems.
        ///        3 == this can lead to performance problems
        ///        4 == this is just not right
        /// </summary>
        /// <param name="errorCode">error code</param>
        /// <returns>severity</returns>
        public static int GetSeverity(JsError errorCode)
        {
            switch (errorCode)
            {
            case JsError.AmbiguousCatchVar:
            case JsError.AmbiguousNamedFunctionExpression:
            case JsError.NumericOverflow:
            case JsError.StrictComparisonIsAlwaysTrueOrFalse:
                return(1);

            case JsError.ArrayLiteralTrailingComma:
            case JsError.DuplicateCatch:
            case JsError.DuplicateConstantDeclaration:
            case JsError.DuplicateLexicalDeclaration:
            case JsError.KeywordUsedAsIdentifier:
            case JsError.MisplacedFunctionDeclaration:
            case JsError.ObjectLiteralKeyword:
                return(2);

            case JsError.ArgumentNotReferenced:
            case JsError.DuplicateName:
            case JsError.FunctionNotReferenced:
            case JsError.UndeclaredFunction:
            case JsError.UndeclaredVariable:
            case JsError.VariableDefinedNotReferenced:
                return(3);

            case JsError.StatementBlockExpected:
            case JsError.SuspectAssignment:
            case JsError.SuspectSemicolon:
            case JsError.SuspectEquality:
            case JsError.WithNotRecommended:
            case JsError.ObjectConstructorTakesNoArguments:
            case JsError.NumericMaximum:
            case JsError.NumericMinimum:
            case JsError.OctalLiteralsDeprecated:
            case JsError.FunctionNameMustBeIdentifier:
            case JsError.SemicolonInsertion:
                return(4);

            default:
                // all others
                return(0);
            }
        }
コード例 #11
0
        internal void HandleError(JsError errorId, bool forceToError)
        {
            if ((errorId != JsError.UndeclaredVariable && errorId != JsError.UndeclaredFunction) || !Document.HasAlreadySeenErrorFor(Code))
            {
                var error = new JsException(errorId, this);

                if (forceToError)
                {
                    error.IsError = true;
                }
                else
                {
                    error.IsError = error.Severity < 2;
                }

                Document.HandleError(error);
            }
        }
コード例 #12
0
            private static Exception ParseException(Exception exception, IEnumerable<string> evaluatedScriptFunctions) {
                var jsErrorJSON = ((exception is AggregateException aggregateException) ? aggregateException.InnerExceptions.FirstOrDefault(e => IsInternalException(e.Message))?.Message : exception.Message) ?? "";

                // try parse js exception
                jsErrorJSON = jsErrorJSON.Substring(Math.Max(0, jsErrorJSON.IndexOf("{")));
                jsErrorJSON = jsErrorJSON.Substring(0, jsErrorJSON.LastIndexOf("}") + 1);

                var evaluatedStackFrames = evaluatedScriptFunctions.Where(f => !string.IsNullOrEmpty(f))
                                                                   .Select(f => new JavascriptStackFrame(f, "eval", 0, 0));

                if (!string.IsNullOrEmpty(jsErrorJSON)) {
                    JsError jsError = null;
                    try {
                        jsError = DeserializeJSON<JsError>(jsErrorJSON);
                    } catch {
                        // ignore will throw error at the end   
                    }
                    if (jsError != null) {
                        jsError.Name = jsError.Name ?? "";
                        jsError.Message = jsError.Message ?? "";
                        jsError.Stack = jsError.Stack ?? "";
                        var jsStack = jsError.Stack.Substring(Math.Min(jsError.Stack.Length, (jsError.Name + ": " + jsError.Message).Length))
                                                   .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

                        var parsedStack = new List<JavascriptStackFrame>();

                        parsedStack.AddRange(evaluatedStackFrames);

                        foreach (var stackFrame in jsStack) {
                            var frameParts = StackFrameRegex.Match(stackFrame);
                            if (frameParts.Success) {
                                parsedStack.Add(new JavascriptStackFrame(frameParts.Groups["method"].Value, frameParts.Groups["location"].Value, int.Parse(frameParts.Groups["column"].Value), int.Parse(frameParts.Groups["line"].Value)));
                            }
                        }

                        return new JavascriptException(jsError.Name, jsError.Message, parsedStack);
                    }
                }

                return new JavascriptException(exception.Message, evaluatedStackFrames, exception.StackTrace);
            }
コード例 #13
0
ファイル: ngControllerBase.cs プロジェクト: mgerasika/gam-gam
 protected void onRequestFailed(JsError jsError, JsString jsString, jqXHR arg3)
 {
     jsUtils.inst.hideLoading();
 }
コード例 #14
0
ファイル: StackTrace.cs プロジェクト: hultqvist/SharpKit-SDK
		public static string GetStackTraceFromError(JsError error) { throw new NotImplementedException(); }
コード例 #15
0
        internal void HandleError(JsError errorId, bool forceToError)
        {
            if ((errorId != JsError.UndeclaredVariable && errorId != JsError.UndeclaredFunction) || !Document.HasAlreadySeenErrorFor(Code))
            {
                var error = new JsException(errorId, this);

                if (forceToError)
                {
                    error.IsError = true;
                }
                else
                {
                    error.IsError = error.Severity < 2;
                }

                Document.HandleError(error);
            }
        }
コード例 #16
0
 public JsScannerException()
 {
     m_errorId = JsError.SyntaxError;
 }
コード例 #17
0
ファイル: Environment.cs プロジェクト: soiqualang/gp5viewer
        static void PlatformInit()
        {
            RenderEngines["svg"]     = () => new CssFontSvgCanvas();
            RenderEngines["default"] = () => new CssFontSvgCanvas();
            RenderEngines["html5"]   = () => new Platform.JavaScript.Html5Canvas();

            // check whether webfont is loaded
            CheckFontLoad();

            JsContext.JsCode("Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; };");

            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As <bool>())
            {
                /**
                 * VB Loader For IE
                 * This code is based on the code of
                 *     http://nagoon97.com/reading-binary-files-using-ajax/
                 *     Copyright (c) 2008 Andy G.P. Na <*****@*****.**>
                 *     The source code is freely distributable under the terms of an MIT-style license.
                 */
                var vbAjaxLoader = new StringBuilder();
                vbAjaxLoader.AppendLine("<script type=\"text/vbscript\">");
                vbAjaxLoader.AppendLine("Function VbAjaxLoader(method, fileName)");
                vbAjaxLoader.AppendLine("    Dim xhr");
                vbAjaxLoader.AppendLine("    Set xhr = CreateObject(\"Microsoft.XMLHTTP\")");
                vbAjaxLoader.AppendLine("    xhr.Open method, fileName, False");
                vbAjaxLoader.AppendLine("    xhr.setRequestHeader \"Accept-Charset\", \"x-user-defined\"");
                vbAjaxLoader.AppendLine("    xhr.send");
                vbAjaxLoader.AppendLine("    Dim byteArray()");
                vbAjaxLoader.AppendLine("    if xhr.Status = 200 Then");
                vbAjaxLoader.AppendLine("        Dim byteString");
                vbAjaxLoader.AppendLine("        Dim i");
                vbAjaxLoader.AppendLine("        byteString=xhr.responseBody");
                vbAjaxLoader.AppendLine("        ReDim byteArray(LenB(byteString))");
                vbAjaxLoader.AppendLine("        For i = 1 To LenB(byteString)");
                vbAjaxLoader.AppendLine("            byteArray(i-1) = AscB(MidB(byteString, i, 1))");
                vbAjaxLoader.AppendLine("        Next");
                vbAjaxLoader.AppendLine("    End If");
                vbAjaxLoader.AppendLine("    VbAjaxLoader=byteArray");
                vbAjaxLoader.AppendLine("End Function");
                vbAjaxLoader.AppendLine("</script>");
                HtmlContext.document.write(vbAjaxLoader.ToString());

                var scriptElement = HtmlContext.document.Member("currentScript").As <HtmlScriptElement>();
                if (!scriptElement.As <bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As <bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As <bool>())
                        {
                            scriptElement =
                                HtmlContext.document.querySelector("script[data-alphatab]").As <HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As <JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As <bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaTab script file for worker, please add the data-alphatab attribute to the script tag that includes alphaTab or provide it when initializing alphaTab");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }
コード例 #18
0
 internal void HandleError(JsError errorId)
 {
     HandleError(errorId, false);
 }
コード例 #19
0
ファイル: qunit-1.9.0.cs プロジェクト: fjgandrade/sharpkit
 /// <summary>
 /// Assertion to test if a callback throws an exception when run.
 /// </summary>
 /// <param name="block"></param>
 /// <param name="expected"></param>
 /// <param name="message"></param>
 /// <remarks>
 /// throws( block: Function(), expected: Error, message: String )
 /// When testing code that is expected to throw an exception based on a specific set of circumstances, use throws() to catch the error object for testing and comparison.
 /// </remarks>
 public static void throws(JsAction block, JsError expected, JsString message) { }
コード例 #20
0
ファイル: LoggingEvent.cs プロジェクト: fjgandrade/sharpkit
 public LoggingEvent(Logger logger, JsDate timeStamp, Level level, JsArray messages, JsError exception) { }
コード例 #21
0
 internal JsScannerException(JsError errorId)
     : base(s_syntaxErrorMsg)
 {
     m_errorId = errorId;
 }
コード例 #22
0
        //---------------------------------------------------------------------------------------
        // ReportError
        //
        //  Generate a parser error.
        //  The function is told whether or not next call to GetToken() should return the same
        //  token or not
        //---------------------------------------------------------------------------------------
        private void ReportError(JsError errorId, JsContext context, bool skipToken)
        {
            Debug.Assert(context != null);
            int previousSeverity = m_severity;
            m_severity = JsException.GetSeverity(errorId);
            // EOF error is special and it's the last error we can possibly get
            if (JsToken.EndOfFile == context.Token)
                EOFError(errorId); // EOF context is special
            else
            {
                // report the error if not in error condition and the
                // error for this token is not worse than the one for the
                // previous token
                if (m_goodTokensProcessed > 0 || m_severity < previousSeverity)
                    context.HandleError(errorId);

                // reset proper info
                if (skipToken)
                    m_goodTokensProcessed = -1;
                else
                {
                    m_useCurrentForNext = true;
                    m_goodTokensProcessed = 0;
                }
            }
        }
コード例 #23
0
 //---------------------------------------------------------------------------------------
 // EOFError
 //
 //  Create a context for EOF error. The created context points to the end of the source
 //  code. Assume the the scanner actually reached the end of file
 //---------------------------------------------------------------------------------------
 private void EOFError(JsError errorId)
 {
     JsContext eofCtx = m_currentToken.Clone();
     eofCtx.StartLineNumber = m_scanner.CurrentLine;
     eofCtx.StartLinePosition = m_scanner.StartLinePosition;
     eofCtx.EndLineNumber = eofCtx.StartLineNumber;
     eofCtx.EndLinePosition = eofCtx.StartLinePosition;
     eofCtx.StartPosition = m_document.Source.Length;
     eofCtx.EndPosition++;
     eofCtx.HandleError(errorId);
 }
コード例 #24
0
 //---------------------------------------------------------------------------------------
 // ReportError
 //
 //  Generate a parser error.
 //  When no context is provided the token is missing so the context is the current position
 //  The function is told whether or not next call to GetToken() should return the same
 //  token or not
 //---------------------------------------------------------------------------------------
 private void ReportError(JsError errorId, bool skipToken)
 {
     // get the current position token
     JsContext context = m_currentToken.Clone();
     ReportError(errorId, context, skipToken);
 }
コード例 #25
0
 //---------------------------------------------------------------------------------------
 // ReportError
 //
 //  Generate a parser error.
 //  When no context is provided the token is missing so the context is the current position
 //---------------------------------------------------------------------------------------
 private void ReportError(JsError errorId)
 {
     ReportError(errorId, false);
 }
コード例 #26
0
 protected void onRequestFailed(JsError jsError, JsString jsString, jqXHR arg3)
 {
 }
コード例 #27
0
 internal void HandleError(JsError errorId)
 {
     HandleError(errorId, false);
 }
コード例 #28
0
 public JsScannerException(string message, Exception innerException)
     : base(message, innerException)
 {
     m_errorId = JsError.SyntaxError;
 }
コード例 #29
0
 public override Exception InternalInit(JsError error)
 {
     return(base.InternalInit(nativeException));
 }
コード例 #30
0
 /// <param name="exc">source exception</param>
 /// <param name="args">arguments</param>
 public GlobalError(JsError exc, JsArray args)
 {
     throw new NotImplementedException();
 }
コード例 #31
0
ファイル: Object.cs プロジェクト: hultqvist/SharpKit-SDK
		public void AssertException(Action<object> callback, JsError exception = null, object re = null, string msg = null) { throw new NotImplementedException(); }
コード例 #32
0
 public JsException(JsError nativeException)
 {
     this.nativeException = nativeException;
 }
コード例 #33
0
 public JsScannerException()
 {
     m_errorId = JsError.SyntaxError;
 }
コード例 #34
0
 public LoggingEvent(Logger logger, JsDate timeStamp, Level level, JsArray messages, JsError exception)
 {
 }
コード例 #35
0
ファイル: Platform.cs プロジェクト: CoderLine/alphaSynth
        private static void PlatformInit()
        {
            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As<bool>())
            {
                var scriptElement = HtmlContext.document.Member("currentScript").As<HtmlScriptElement>();

                if (!scriptElement.As<bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As<bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As<JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As<bool>())
                        {
                            scriptElement = HtmlContext.document.querySelector("script[data-alphasynth]").As<HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As<JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (!string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As<bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaSynth script file for worker, please add the data-alphasynth attribute to the script tag that includes alphaSynth or provide it when initializing alphaSynth");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }
コード例 #36
0
 /// <summary>
 /// Returns whether the logger is enabled for the specified level
 /// </summary>
 /// <param name="level"></param>
 /// <param name="exception"></param>
 /// <returns></returns>
 public JsBoolean isEnabledFor(Level level, JsError exception)
 {
     return(false);
 }
コード例 #37
0
 internal JsScannerException(JsError errorId)
     : base(s_syntaxErrorMsg)
 {
     m_errorId = errorId;
 }
コード例 #38
0
 /// <summary>
 /// Assertion to test if a callback throws an exception when run.
 /// </summary>
 /// <param name="block"></param>
 /// <param name="expected"></param>
 /// <param name="message"></param>
 /// <remarks>
 /// throws( block: Function(), expected: Error, message: String )
 /// When testing code that is expected to throw an exception based on a specific set of circumstances, use throws() to catch the error object for testing and comparison.
 /// </remarks>
 public static void throws(JsAction block, JsError expected, JsString message)
 {
 }
コード例 #39
0
 public JsScannerException(string message, Exception innerException)
     : base(message, innerException)
 {
     m_errorId = JsError.SyntaxError;
 }
コード例 #40
0
ファイル: Environment.cs プロジェクト: CoderLine/alphaTab
        static void PlatformInit()
        {
            RenderEngines["svg"] = () => new FontSvgCanvas();
            RenderEngines["default"] = () => new FontSvgCanvas();
            RenderEngines["html5"] = () => new Platform.JavaScript.Html5Canvas();
            FileLoaders["default"] = () => new Platform.JavaScript.JsFileLoader();

            // check whether webfont is loaded
            CheckFontLoad();

            JsContext.JsCode("Math.log2 = Math.log2 || function(x) { return Math.log(x) * Math.LOG2E; };");

            // try to build the find the alphaTab script url in case we are not in the webworker already
            if (HtmlContext.self.document.As<bool>())
            {
                var scriptElement = HtmlContext.document.Member("currentScript").As<HtmlScriptElement>();

                if (!scriptElement.As<bool>())
                {
                    // try to get javascript from exception stack
                    try
                    {
                        var error = new JsError();
                        var stack = error.Member("stack");
                        if (!stack.As<bool>())
                        {
                            throw error;
                        }

                        ScriptFile = ScriptFileFromStack(stack.As<JsString>());
                    }
                    catch (JsError e)
                    {
                        var stack = e.Member("stack");
                        if (!stack.As<bool>())
                        {
                            scriptElement = HtmlContext.document.querySelector("script[data-alphatab]").As<HtmlScriptElement>();
                        }
                        else
                        {
                            ScriptFile = ScriptFileFromStack(stack.As<JsString>());
                        }
                    }
                }

                // failed to automatically resolve
                if (string.IsNullOrEmpty(ScriptFile))
                {
                    if (!scriptElement.As<bool>())
                    {
                        HtmlContext.console.warn(
                            "Could not automatically find alphaTab script file for worker, please add the data-alphatab attribute to the script tag that includes alphaTab or provide it when initializing alphaTab");
                    }
                    else
                    {
                        ScriptFile = scriptElement.src;
                    }
                }
            }
        }
コード例 #41
0
 public void AssertException(Action <object> callback, JsError exception = null, object re = null, string msg = null)
 {
     throw new NotImplementedException();
 }
コード例 #42
0
ファイル: Logger.cs プロジェクト: hultqvist/SharpKit-SDK
 /// <summary>
 /// Returns whether the logger is enabled for the specified level
 /// </summary>
 /// <param name="level"></param>
 /// <param name="exception"></param>
 /// <returns></returns>
 public JsBoolean isEnabledFor(Level level, JsError exception) { return false; }
コード例 #43
0
ファイル: GlobalError.cs プロジェクト: fjgandrade/sharpkit
		/// <param name="exc">source exception</param>
		/// <param name="args">arguments</param>
		public GlobalError(JsError exc, JsArray args) { throw new NotImplementedException(); }
コード例 #44
0
 public static string GetStackTraceFromError(JsError error)
 {
     throw new NotImplementedException();
 }
コード例 #45
0
ファイル: Exception.cs プロジェクト: dzeitlin/WootzJs
 public Exception InternalInit(JsError error)
 {
     stacktrace    = error.stack;
     toStringSaved = toString();
     return(this);
 }
コード例 #46
0
        /// <summary>
        /// Return the default severity for a given JSError value
        /// guide: 0 == there will be a run-time error if this code executes
        ///        1 == the programmer probably did not intend to do this
        ///        2 == this can lead to cross-browser of future problems.
        ///        3 == this can lead to performance problems
        ///        4 == this is just not right
        /// </summary>
        /// <param name="errorCode">error code</param>
        /// <returns>severity</returns>
        public static int GetSeverity(JsError errorCode)
        {
            switch (errorCode)
            {
                case JsError.AmbiguousCatchVar:
                case JsError.AmbiguousNamedFunctionExpression:
                case JsError.NumericOverflow:
                case JsError.StrictComparisonIsAlwaysTrueOrFalse:
                    return 1;

                case JsError.ArrayLiteralTrailingComma:
                case JsError.DuplicateCatch:
                case JsError.DuplicateConstantDeclaration:
                case JsError.DuplicateLexicalDeclaration:
                case JsError.KeywordUsedAsIdentifier:
                case JsError.MisplacedFunctionDeclaration:
                case JsError.ObjectLiteralKeyword:
                    return 2;

                case JsError.ArgumentNotReferenced:
                case JsError.DuplicateName:
                case JsError.FunctionNotReferenced:
                case JsError.UndeclaredFunction:
                case JsError.UndeclaredVariable:
                case JsError.VariableDefinedNotReferenced:
                    return 3;

                case JsError.StatementBlockExpected:
                case JsError.SuspectAssignment:
                case JsError.SuspectSemicolon:
                case JsError.SuspectEquality:
                case JsError.WithNotRecommended:
                case JsError.ObjectConstructorTakesNoArguments:
                case JsError.NumericMaximum:
                case JsError.NumericMinimum:
                case JsError.OctalLiteralsDeprecated:
                case JsError.FunctionNameMustBeIdentifier:
                case JsError.SemicolonInsertion:
                    return 4;

                default:
                    // all others
                    return 0;
            }
        }