IOS – Debug iPhone Mobile Safari without Web Inspector

developmentiosiphonepython

I'm using Pythonista, a mobile Python environment to code on my iPhone while I'm on the train with no laptop around. I've started working on a small web application using bottle and d3.js. However, finding javascript errors in Safari is impossible. There is simply no way to find out what error stopped the application.

Is there a workaround for this?

Best Answer

I found a way to do this. It's a little dirty but it works and it helps a lot with scripting for the browser.

Simply put a try...catch block around the code you're want to debug and use alert() to output the information to you. Like this:

try {
  // some code that might go wrong
catch (e) {
  alert(e);
  alert(e.stack);
}