With Codebase Exceptions, you can setup your application to report exceptions straight back to your Codebase interface.

Just navigate to your chosen project, and click the Exceptions Tab.

We will cover a few of the environments you can setup for reporting exceptions to Codebase.

Using Ruby on Rails

If you haven't set up Airbrake Notifier, you can set it up as below, otherwise skip this step.

  1. Add gem 'airbrake', '~> 5.4' to your Gemfile
  2. Copy the configuration shown above to config/initializers/airbrake.rb.
  3. Run rake airbrake:test to see if things are working.

Next you just need to open up config/initializers/airbrake.rb as shown below. Once done, you can run rake airbrake:test to see if everything is working as you expect.

Airbrake.configure do |config|
  config.host = 'https://exceptions.codebasehq.com'
  config.project_key = 'ac0357b1-f44a-8ed6-6d31-179041949810'
  config.project_id = '12345'
end

Using PHP/Composer

Full details of the PHP Airbrake library can be found on the project page.

Install phpbrake (requires composer)

composer require airbrake/phpbrake

Include the exception handler in your code and configure it to point to Codebase

// Create new Notifier instance, pointing to Codebase
$notifier = new Airbrake\Notifier(array(
       'projectID' => 4,
       'projectKey' => 'ac0357b1-f44a-8ed6-6d31-179041949810',
       'host' => 'https://exceptions.codebasehq.com'
    )
);

// Set global notifier instance.

Airbrake\Instance::set($notifier);

// Register error and exception handlers.

$handler = new Airbrake\ErrorHandler($notifier);
$handler->register();

// Somewhere in the app...

try {
   throw new Exception('hello from phpbrake');
} catch(Exception $e) {
    Airbrake\Instance::notify($e);
}

Using node.js

Full details of the node-airbrake project can be found on their project page.

Firstly, install node-airbrake through npm:

npm install airbrake

Now add the exception handler to your node app:

var airbrake = require('airbrake').createClient("ac0357b1-f44a-8ed6-6d31-179041949810");
airbrake.serviceHost = "https://exceptions.codebasehq.com"
airbrake.handleExceptions();

Using Python/Django

Full details of the django-airbrake project can be found on their pypi page.

Firstly, install django-airbrake with pip:

pip install django-airbrake

Now add airbrake.handlers.AirbrakeHandler as a logging handler:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'airbrake': {
            'level': 'WARNING',
            'class': 'airbrake.handlers.AirbrakeHandler',
            'filters': ['require_debug_false'],
            'project_key': 'ac0357b1-f44a-8ed6-6d31-179041949810',
            'project_id': 12345,
            'env_name': 'develop',
            'api_url' : ''https://exceptions.codebasehq.com/notifier_api/v2/notices',
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['airbrake'],
            'level': 'WARNING',
            'propagate': True,
        },
    }
}

Using .NET

The .NET notifier is compatible with C# and VB.NET.

Full details and configuration instructions for the airbrake-dotnet project can be found at the project page.

Using Delphi

This plugin allows Delphi error notifications to be sent to Codebase using madexcept.

Full details and installation instructions can be found at the project page.

Using anything else?

Since Codebase exceptions is Airbrake compatible, you should be able to use any available Airbrake notifier. Simply ensure that the notifier is set to send notifications to exceptions.codebasehq.com. Notifiers are available for most platforms.

API compatibility

Codebase's exceptions handler conforms to the Airbrake spec, so if you need to craft your own exception handler, you can.

Just make sure your data conforms to the spec, and send it to https://exceptions.codebasehq.com.

Tell us how you feel about this post?