Catching unforeseen JavaScript errors

JavaScript errors can originate from anywhere inside your code or the libraries you’re using. Because they are runtime exceptions you’re not alerted to them whilst you’re writing your code. So you might not be aware of all the possible errors that might occur. Failing to foresee a specific error occurring might not turn out to be dramatic. Most of the time, the error is simply logged to the console and the application continues to functions properly. Sometimes they may lead to your browser freezing. But in the most problematic of cases you’re program may continue to appear to function correctly but the outcome is faulty.

How to deal with an error largely depends on the specific type of error and the context in which it has manifested itself. So there’s no silver bullet to be found on how to deal with unforeseen errors. But at least making sure that any uncaught errors don’t go unnoticed seems essential. Continue reading “Catching unforeseen JavaScript errors”

Server side logging from browser side JavaScript code

Application logging is something we all do in our applications that get deployed on an application server, right? Using frameworks like Log4J or Logback seems like a no-brainer to most Java developers. But what about the code we’ve written that is running in those pesky browsers? I guess that, apart from the occasional console.log() statement used during debugging, we don’t give much thought to JavaScript logging. I find this situation very regrettable since nowadays the trend appears to be to move our application logic to the browser. And with it, interesting events happening in the browser might go unnoticed, or any bugs that will happen, no matter how well we’ve developed and tested our client side code, might prove needlessly hard to reproduce and therefore fix. In this blog post I’ll demonstrate a very basic setup to log messages from the browser on the server using some very basic JavaScript with jQuery, and a simple Spring controller with Slf4J. Continue reading “Server side logging from browser side JavaScript code”

My JavaScript book recommendations

I’ve been using JavaScript since the late 1990s – the era of the first browser wars between Netscape Navigator and Internet Explorer. At the time it was just to liven up the static html pages with some mouse over effects. Since the early 2000s it was all about simple form validations. But from 2008 onwards – thanks to the arrival of jQuery and the meanwhile ubiquitous presence of Ajax – the use of JavaScript has exploded. I’ve been using jQuery extensively since 2009, mainly to enhance to user experience of the web sites and applications that I’ve developed.

Probably due to the vast number of jQuery plugins that are available, I’ve never felt the need to really deepen my knowledge of the JavaScript language. That is, up until november 2012, the time I first came in to contact with the amazing framework that is called AngularJS. As a veteran Java developer AngularJS I was immediately very charmed by the framework because on the one hand there were all these familiar concepts like dependency injection, the MVC pattern, modularity, data binding, etc., whilst on the other hand my productivity soared using AngularJS instead of server side Java frameworks like Wicket or JSF. Continue reading “My JavaScript book recommendations”

A very simple RSS reader with AngularJS and Google Feed API

Last year I’ve written a few lines about aggregating feeds with SimplePlie. SimplePie is a nice PHP library but the version I used broke when my hosting provider decided to upgrade the servers to a new PHP version. Although a new version was quickly installed, I found the broken pages to be the perfect motivation to finally do some coding with AngularJS.So after having attended a few workshops about AngularJS, and having read the excellent book by Brad Green and Shyam Seshadri, I finally got around to do some actual work with the framework.

Continue reading “A very simple RSS reader with AngularJS and Google Feed API”