Chrome Developer: Understanding Stack Traces

One of the biggest challenges in JavaScript development is dealing with script errors. We’ve been working hard to improve and extend the set of tools that lets you better understand how your JavaScript code works. Let’s have a quick look at five features of Google Chrome Developer Tools that can help you work with exceptions and stack traces more efficiently:

  • Exception call stack. When something goes wrong, you can open the developer tools console. There you’ll find a number of uncaught JavaScript exception messages there. Each message has a link to the file name with the line number you can navigate to. However, there might be several execution paths that lead to the error and it’s not always obvious which one of them has happened. Exceptions in the console are now accompanied with the complete JavaScript call stacks after the developer tools window has been opened.
  • Pause on exception. The developer tools’ Scripts panel enables you to pause JavaScript execution each time an exception is thrown and inspect its call stack, scope variables and state of your app. You can choose whether to pause only on uncaught exceptions or on all exceptions.
  • Logging stack traces. Printing log messages to the developer tools console is also very helpful in understanding how your application behaves. Now you can make the log entries even more informative by including associated stack traces. You can instrument your code with console.trace() calls that would print current JavaScript call stack. Moreover, you can check that some invariants are true using console.assert() which prints a full stack trace when its conditional expression passed as first parameter evaluate to false.
  • Error.stack. Each Error object has a property named “stack” that contains the stack trace.
  • Handler function for window.onerror. Recently we’ve added support for setting a handler function to window.onerror. Whenever a JavaScript exception is thrown in the window context and is not caught by any try/catch block, the function will be invoked with the exception’s message, the URL of the file where the exception was thrown and the line number in that file passed as three arguments in that order. You may find it convenient to set an error handler that would collect information about uncaught exceptions and report it back to your server.

For a more complete reference on working with the Google Chrome Developer Tools, check out our home page. We further described improvements to exception handling and stack traces in our recent WebKit blog post.

Latest news: The protests in Syria escalate

Syria News

[map maptype=”ROADMAP” w=”640″ h=”400″ z=”6″ lat=”34.4341″ lon=”37.38647″ marker=”yes” infowindow=”Syria in protests“]

Syria’s harsh and stagnant dictatorship at first seemed immune to the wave of unrest that swept through most of the Arab world after the revolution in Tunisia in January 2011. But in mid-March, demonstrations broke out in several cities, and grew rapidly after security forces fired on protesters.

The country’s president is Bashar al-Assad, the son of Hafez al-Assad, who ruled with an iron hand for three decades before his death in 2000. The Assads belonged to the Allawite sect, a minority that came to hold most of the top positions in the government and military. Under Hafez al-Assad, Syria was reviled in the West for its support of terrorist groups and generally isolated even from more moderate Arab countries. Bashar al-Assad from time to time made gestures toward greater openness. But it remained one of the region’s most repressive regimes.

In February 2011, after the fall of Egypt’s strongman, Hosni Mubarak, a handful of demonstrations were called in Syria. But the demonstrators were always outnumbered by the police, and were quickly arrested or dispersed. Large protests began in March in the southern town of Dara’a, where citizens were outraged by the arrest of more than a dozen schoolchildren for writing graffiti. More protests followed, in Dara’a and other parts of the country; after a few days, the regime responded with force. By April 30, human rights groups said they had documented close to 500 deaths of protesters.

The widening defiance in Syria comes after months of challenge to the autocrats of the Arab world that confronts them with a stark choice: either they can step down, as the leaders of Tunisia and Egypt were forced to do, or they can protect their own power with varying degrees of force, like the rulers of Libya, Bahrain and Yemen, at the risk of ever greater violence.

In Syria, Mr. Assad at first seemed to veer between offers of concessions and force. On April 16, Mr. Assad pledged to meet one of the demonstrators’ main demands by lifting the emergency law. But just days later, he launched what became a withering crackdown: security forces fired on demonstrators across the country, killing dozens, the army sent tanks into Dara’a and hundreds of government opponents were arrested or were reported to have disappeared. On May 5, Insan, a Syrian human rights group, said that more than 600 people had been killed and as many as 8,000 people were reported to be in custody or missing.

Syria’s security forces shot dead 30 people yesterday as thousands rallied on a “Day of Defiance” against Bashar al-Assad’s rule.
The president’s forces opened fire and sent tanks to attack protesters.
About 100 tanks were stationed between the outskirts of Damascus and Homs.
The latest killings came as a divided European Union failed to agree on sanctions to target President Assad despite his regime’s history of violence. After talks in Brussels, a group of southern European countries blocked measures to issue a travel ban and freeze the president’s assets.
Visa bans and asset freezes were agreed for 13 officials beneath the president but no measures were taken to cut off Syria’s wealth by targeting its oil industry or blocking exports to the EU.

Enhancements to the mountains in Google Earth

While Google continues to add great new features and tons of new imagery to Google Earth, they want to be clear that they’re not forgetting about some of the basic layers such as the Mountains and Water bodies.

A few days ago they pushed out an update to the Mountains layer which includes some powerful new features, including a detailed information window, Panoramio photos, cross-section views of the mountain and tours that they’ve created for every mountain. For example, here is a video showing the tour of the Matterhorn:

For this feature to work, you need to enable the “Mountains” layer on the left-hand panel in Google Earth. Of course, an increasingly difficult challenge is finding the proper layers as Google continues to add more of them. For the Mountains, you’ll find it under “Borders and Labels” –> “Labels” –> “Mountains”, as shown here:

layers_panel.png

In addition to the mountain layer changes, they’ve added thousands of new labels to the “Water Bodies” layer, which can be found just below the “Mountains” layer in the image above.

Hopefully Google will continue to finesse the organization of the layers section and make it easier to find the hidden gems like this one.