Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some more error types and a simple way to trigger them

  • Loading branch information...
commit 8c9bf65246358134a0ae7f8510dded70d6073518 1 parent 330f0da
@elandesign authored
View
2  Gemfile
@@ -6,7 +6,7 @@ gem 'rails', '3.2.6'
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
-gem 'airbrake'
+gem 'airbrake-amqp', :path => '/Users/freeagent/Desktop/airbrake-amqp'
# Gems used only for assets and not required
View
10 Gemfile.lock
@@ -1,3 +1,10 @@
+PATH
+ remote: /Users/freeagent/Desktop/airbrake-amqp
+ specs:
+ airbrake-amqp (0.0.1)
+ airbrake
+ bunny
+
GEM
remote: https://rubygems.org/
specs:
@@ -33,6 +40,7 @@ GEM
builder
arel (3.0.2)
builder (3.0.0)
+ bunny (0.8.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -106,7 +114,7 @@ PLATFORMS
ruby
DEPENDENCIES
- airbrake
+ airbrake-amqp!
coffee-rails (~> 3.2.1)
jquery-rails
rails (= 3.2.6)
View
4 app/controllers/application_controller.rb
@@ -1,3 +1,7 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
+ def generate_error
+ Errors.send(params[:name])
+ end
end
View
8 app/controllers/users_controller.rb
@@ -1,15 +1,9 @@
class UsersController < ApplicationController
def index
- @users = User.all
end
def new
- @user = User.new(:name => 'Frank')
- @user.save!
- end
-
- def edit
- @user = User.find(params[:id])
end
+
end
View
2  app/views/layouts/application.html.erb
@@ -2,8 +2,6 @@
<html>
<head>
<title>ErrbitTester</title>
- <%= stylesheet_link_tag "application", :media => "all" %>
- <%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
View
14 app/views/users/index.html.erb
@@ -1 +1,13 @@
-<%= 120 / 0 %>
+<h1>Generate Some Errors</h1>
+
+<ul>
+ <li><%= link_to 'ZeroDivisionError', error_path(:name => :divide_by_zero) %></li>
+ <li><%= link_to 'ActiveRecord::RecordInvalid', error_path(:name => :record_invalid) %></li>
+ <li><%= link_to 'NoMethodError', error_path(:name => :no_method_error) %></li>
+ <li><%= link_to 'ArgumentError', error_path(:name => :argument_error) %></li>
+ <li><%= link_to 'SystemStackError', error_path(:name => :system_stack_error) %></li>
+ <li><%= link_to 'Custom RuntimeError', error_path(:name => :custom_runtime_error) %></li>
+ <li><%= link_to 'Custom Exception', error_path(:name => :custom_exception) %></li>
+ <li><%= link_to 'ActionView::MissingTemplate', new_user_path %></li>
+ <li><%= link_to 'NameError', error_path(:name => :name_error) %></li>
+</ul>
View
2  config/application.rb
@@ -16,7 +16,7 @@ class Application < Rails::Application
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
- # config.autoload_paths += %W(#{config.root}/extras)
+ config.autoload_paths += %W(#{config.root}/lib)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
View
12 config/initializers/airbrake.rb
@@ -1,7 +1,7 @@
Airbrake.configure do |config|
- # config.api_key = '74586ade4b7820f76a15bbc77862963e'
- config.api_key = '0c3409fc29b6dd0e26b0680e86acb16f'
- config.host = 'errbit.lvh.me'
- config.port = 3000
- # config.secure = config.port == 443
- end
+ config.api_key = 'ddea4813baa82123347a34b2f7556be1'
+end
+
+Airbrake::Amqp.configure do |config|
+ config.uri = 'amqp://guest:guest@localhost:5672/airbrake'
+end
View
3  config/routes.rb
@@ -1,6 +1,9 @@
ErrbitTester::Application.routes.draw do
root :to => 'users#index'
+
+ match "errors/:name" => 'application#generate_error', :as => :error
+
resources :users do
resources :tasks
end
View
39 lib/errors.rb
@@ -0,0 +1,39 @@
+class Errors
+ class << self
+ def divide_by_zero
+ 1000 / 0
+ end
+
+ def record_invalid
+ User.new.save!
+ end
+
+ def no_method_error
+ User.new.no_method!
+ end
+
+ def argument_error
+ record_invalid(1, 2, 3)
+ end
+
+ def system_stack_error
+ system_stack_error
+ end
+
+ def custom_runtime_error
+ raise "This is a custom RuntimeError"
+ end
+
+ def custom_exception
+ raise MyExceptionClass.new('This is a custom Exception')
+ end
+
+ def missing_template_path
+ '/users/new'
+ end
+
+ def name_error
+ NoSuchClass.new
+ end
+ end
+end
View
2  lib/my_exception_class.rb
@@ -0,0 +1,2 @@
+class MyExceptionClass < Exception
+end
Please sign in to comment.
Something went wrong with that request. Please try again.