NodeJS web frameworks and capturing errors

Daniel WylieProvider Updates, Resource1 Comment


So you’re just about to start your sweet new NodeJS project? Awesome! Let’s be friends. Since you’re just starting out, you probably haven’t thought about exceptions yet, have you? No worries – I won’t tell anyone. Let’s have a look at how the raygun4node module integrates with a few of the NodeJS web frameworks you’ll most likely be looking at.


The almost-defacto framework for building web applications in NodeJS, ExpressJS makes it easy to integrate with the Raygun, you simply use:

Place it at the bottom of your middleware definitions and you’re away laughing.


Hapi is a lightweight library that focuses on reusable code and less on writing configuration code. Again, it’s super simple to integrate Raygun into Hapi’s workflow:


Building REST Apis? There’s a module for that! And it’s brilliant. Meet Restify. But catching errors you ask – here you go!


Koa is a newish framework from the guys who did ExpressJS with a whole bunch of new thinking. They made dealing with errors pretty easy. Because we have no routes, this sample throws two errors, but that won’t happen normally though of course!

But I’m feeling hardcore and want to deal with raw HTTP?

Boom, nice work! You’re probably pretty good at NodeJS already, so you don’t really need help right? Well I’m going to anyway! The easiest way to capture errors without a framework is using the domains feature of NodeJS. You simply wrap your app up in a domain and deal with the error event.

Interested in trying professional-grade error tracking? All of these insights and more are available with Raygun, so start your free 14 day trial now, no credit card needed. Happy exception blasting!

Next level software intelligence across your entire stack.

One Comment on “NodeJS web frameworks and capturing errors”

  1. Pingback: Cheatsheet: 2015 04.01 ~ 04.30 | ITblog

Leave a Reply

Your email address will not be published. Required fields are marked *