I started a Javascript Stacktrace project back in August 2008. The idea was to give additional debugging power to browsers where you don’t have good tools to work with. I’d like to give you an update on where the project is today.
Lately, I’ve been working on updating my old script. Since it was written, we’ve seen lots of major browser releases and the introduction of the V8 Javascript engine used byGoogle Chrome.
Updated browser compatibility
Browsers that are fully-supported and well-tested:
- Firefox (and Iceweasel) 0.9+
- UPDATE: Chrome 1+ now perfectly supported
- Safari 3+
- IE 5.5+
- Opera 9+
- Konqueror 3.5+
- K-Meleon 1.5.3+
- Epiphany 2.28.0+
Browsers that are supported in almost all cases but not as well-tested:
-
Chrome 1+ – One bug (feature?) that may be in Chrome reporting functions as anonymous when they aren’t. HOWEVER, Chrome’s stack gives us line numbers AND column numbers, so we can see exactly where our problem is – even in minified Javascript! Sweet!Chrome 1+ now fully supported.
- Opera 7-8 – Opera is dead to me now. Opera 10+ has removed the error.stack info we needed and introduced error.stacktrace, but it seems very unstable. Argh.
More info about compatibility can be shown with theBrowserShots of the test suite.
Now socially coded
I’m not going to post the code here because the source and tests are now on the javascript-stacktrace project on GitHub. You can download it here.
Follow it, file bugs, and make comments there. If you have improvements to make, please fork the project and then contact me or do a “push request”. I’ll make sure you get credit ;)
UPDATE: Øyvind Sean Kinsey has added memoization (caching the implementation) for the mode and XHR bits as well as the ability to pass an existing Javascript Error and get a stacktrace. We’re working on tests and you should see project updates soon. Thanks, Øyvind!
var lastError;
try {
// error producing code
} catch(e) {
lastError = e;
// do something else with error
}
// later...
printStackTrace({e: lastError}); //Returns stacktrace from lastError!
Try it out!
The code is in use on my blog. Click here to give it a spin.
function foo() {
var blah;
bar("blah");
}
function bar(blah) {
var stuff;
thing();
}
function thing() {
if (true) { //your error condition here
var st = printStackTrace();
alert(st.join("\n\n"));
}
}
foo();
Random note: one cool suggestion I saw was to assign printStackTrace to window.onerror. Pretty brilliant if you ask me.
I want to thank the guys who contributed to the script:Luke Smith, Loic Dachary and Johan Euphrosine.
I could use a bit of help getting the Chrome and Opera bugs worked out. I’m sure some of you guys who remember how to write software can help. Suggestions and whinings are welcome as long as they don’t get out of hand in the comments.
Javascript Stacktrace on GitHub
分享到:
相关推荐
利用 Exception 的StackTrace 属性获得错误的文件的位置(文件名,行号),并将错误信息保存在一个.config的文件里,内容有: 如何获取错误 如何获取错误的位置,多层开发时,在类用应用此法方便查错 如保获取站点的...
matlab开发-用StackTrace替换键盘。显示堆栈跟踪,显示使用键盘的位置
前端项目-stacktrace.js,框架不可知的微型库,用于在所有环境中获取堆栈跟踪
stacktrace.js 在所有浏览器中生成,解析和增强JavaScript堆栈跟踪 使用导致错误(或您指定的任何条件)的函数调用来调试和配置JavaScript。 stacktrace.js使用浏览器的Error.stack机制生成堆栈跟踪,对其进行...
Android studio Run with –stacktrace option to get the stack trace. Run with –info or –debu 提示信息 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get ...
主要介绍了 Android studio 出现错误Run with --stacktrace option to get the stack trace. Run with --info or --debu的相关资料,需要的朋友可以参考下
有时候当你的程序崩溃时能获得堆栈轨迹是很有用处的。很多人认为当程序崩溃时用C/C++难以获知程序在哪出现了错误。在很大程度上,C/C++的确难以做到,但是调试器却能做到这一点。下文给出的程序可以做到不用调试器却...
Atom-stacktrace.zip,用于导航stacktraces的atom包。原子的stacktrace,atom是一个用web技术构建的开源文本编辑器。
详细请参见文章 : https://blog.csdn.net/u011039332/article/details/83045246
开源项目-palantir-stacktrace.zip,Palantir的StackTrace库
安装NPM npm install axios-better-stacktrace 纱yarn add axios-better-stacktrace笔记已使用axios 0.21.0进行了测试。用法// CommonJS// const axiosBetterStacktrace = require('axios-better-stacktrace')....
前端开源库-atma-loader-stacktraceATMA加载程序stacktrace,用于编译/缩小脚本的stacktrace
git-stacktrace:轻松找出哪个git commit导致了给定的stacktrace
A beautiful stack trace pretty printer for C++
Android远程Stacktrace:改进 该项目是,它添加了许多重要功能: 可定制的接口,用于处理堆栈跟踪 通过将堆栈跟踪保存到自己的目录而不是应用程序的根文档目录,从而更好地处理文件系统 允许可选的调试日志记录,这...
vim-stacktrace-Vim脚本的Stacktrace 信用证:/ vim-stacktrace提供了一种通过错误信息(例如v:throwpoint ,错误消息)获取调用堆栈或构建堆栈v:throwpoint 。 您可以从结果中创建快速修复列表或位置列表。 vim...
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
这是从 google 代码导出的 android 崩溃报告自动上传项目的副本。 android-remote-stacktrace 从 code.google.com/p/android-remote-stacktrace 自动导出
python库。 资源全名:git-stacktrace-0.8.0.tar.gz