WebService::Raygun::Messenger - Communicate with the Raygun.io endpoint.
use Try::Tiny; use WebService::Raygun::Messenger; sub some_code { try { # Code that throws an exception # ... } catch { my $exception = $_; my $message = { error => $exception, # $@ or framework exception (eg. Moose::Exception) request => $request_object, # i.e. HTTP::Request, Catalyst::Request, etc. #... other params }; # initialise raygun.io messenger my $raygun = WebService::Raygun::Messenger->new( api_key => '<your raygun.io api key>', message => $message ); # send message to raygun.io my $response = $raygun->fire_raygun; }; }
Send a request to raygun.io.
WebService::Raygun::Messenger, as well as most of the other classes in this package, accepts a HASHREF in the constructor which is then coerced into datatypes that will eventually be sent to Raygun. It is generally not necessary to initialise any of these objects yourself. For the most part, the class hierarchy in this package maps to the API shown on the Raygun api docs.
HASHREF
Your raygun.io API key. By default, this will be whatever is in the RAYGUN_API_KEY environment variable.
RAYGUN_API_KEY
This can be one of the following
{ occurred_on => '2014-06-27T03:15:10+1300', error => $error_obj, # eg. Catalyst::Exception, Moose::Exception user => 'test@test.com', environment => { processor_count => 2, cpu => 34, architecture => 'x84', total_physical_memory => 3 ... }, request => $request_object }
The HASHREF with the structure above will be coerced into this type of object. See WebService::Raygun::Message for a more detailed description of this object.
Send data to api.raygun.io/entries via a POST request.
Constructs the actual message. See this class for a better description of the fields available or required for the raygun.io API.
To install WebService::Raygun, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::Raygun
CPAN shell
perl -MCPAN -e shell install WebService::Raygun
For more information on module installation, please visit the detailed CPAN module installation guide.