Scala and Play 2 framework now supported by Raygun

| 2 min. (409 words)

Hot on the heels of the recent announcement of Raygun’s support for iOS with our official provider comes an addition to our Java provider – Play 2 Framework support!

Play 2 exception tracking support for Scala and Java

Not heard of Play? Play 2 is a modern MVC web framework which allows you to build fast, scalable applications for the web, in Java or Scala. Raygun4Java already supports a couple of web frameworks, including servlet-based ones (Google App Engine included). The latest 1.4.1 release includes an alpha release of a new Maven module, raygun4java-play2, which has full support for transmitting exceptions from Play 2 controllers and view models.

The addition of this module brings the Scala language into the official supported languages list for Raygun. You can already send exceptions from Scala by using the vanilla Raygun4Java package; the new Play 2 support brings one crucial benefit – first-class HTTP request data visibility.

Send HTTP Request Data

One of the killer features for Play 2 is support for both of the above JVM languages. The framework supports this by placing Java libraries inside play.mvc.*, while the corresponding Scala API is generally available from _play.api.__. The controllers you write make the Http.Request object available which contains standard data like the URL, query string, body, form data, etc. Often this can give you a crucial insight when debugging web exceptions remotely. Play 2 does however have separate Request objects for Java and Scala.

Raygun4Java-Play2 supports this by accepting either Request in its constructor, so you can use both without concerning yourself with the low-level details.

Here’s a usage example, from a Scala Play 2 controller:

import play.api.mvc.{Action, Controller, Request}
import com.mindscapehq.raygun4java.play2.RaygunPlayClient;

def index = Action { implicit request =>
    val rg = new RaygunPlayClient("your_api_key", request)
    val result = rg.Send(new Exception("From Scala"))
    Ok(views.html.index(result.toString))
  }

Getting it

If you’re using Maven, you can grab the provider by adding this package to your dependencies, or download the JAR from that same link if you’re using another build tool (then place it in your project’s lib/ folder). It’s currently at version 0.4.3 alpha, and feedback is appreciated. Give it a spin in a staging environment before deploying to production as it’s an alpha release.

If you’re a Play 2 or Scala dev and interested in plugging Raygun into your project, start your free trial now (no credit card needed) or if you have any questions let us know in the comments below. Happy error blasting!