Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a more complete solution (I think I grabbed it from the ELMAH site... can't remember)</p> <p>ErrorLogging.js:</p> <pre><code> window.onerror = function (msg, url, line) { logError(msg, arguments.callee.trace()); } function logError(ex, stack) { if (ex == null) return; if (logErrorUrl == null) { alert('logErrorUrl must be defined.'); return; } var url = ex.fileName != null ? ex.fileName : document.location; if (stack == null &amp;&amp; ex.stack != null) stack = ex.stack; // format output var out = ex.message != null ? ex.name + ": " + ex.message : ex; out += ": at document path '" + url + "'."; if (stack != null) out += "\n at " + stack.join("\n at "); // send error message jQuery.ajax({ type: 'POST', url: logErrorUrl, data: { message: out } }); } Function.prototype.trace = function() { var trace = []; var current = this; while(current) { trace.push(current.signature()); current = current.caller; } return trace; } Function.prototype.signature = function() { var signature = { name: this.getName(), params: [], toString: function() { var params = this.params.length &gt; 0 ? "'" + this.params.join("', '") + "'" : ""; return this.name + "(" + params + ")" } }; if (this.arguments) { for(var x=0; x&lt;this.arguments.length; x++) signature.params.push(this.arguments[x]); } return signature; } Function.prototype.getName = function() { if (this.name) return this.name; var definition = this.toString().split("\n")[0]; var exp = /^function ([^\s(]+).+/; if (exp.test(definition)) return definition.split("\n")[0].replace(exp, "$1") || "anonymous"; return "anonymous"; } </code></pre> <p>Layout/Master Page:</p> <pre><code>&lt;script src="@Url.Content( "~/Scripts/ErrorLogging.js" )" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; //This needs to be here to be on everypage var logErrorUrl = '@Url.Action( "LogJavaScriptError", "Home" )'; &lt;/script&gt; </code></pre> <p>HomeController.cs:</p> <pre><code> [HttpPost] public void LogJavaScriptError( string message ) { ErrorSignal.FromCurrentContext().Raise( new JavaScriptErrorException( message ) ); } </code></pre> <p>JavaScriptErrorException.cs:</p> <pre><code>[Serializable] public class JavaScriptErrorException: Exception{ public JavaScriptErrorException( string message ) : base ( message ){} } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload