Skip to content
Browse files

error tracking tracks query for easier reproduction and debugging

  • Loading branch information...
1 parent c80b48c commit ac6269a6e53a46c63fec6188b46bff5bbf02e9d5 @jrochkind committed
View
4 app/controllers/battle_controller.rb
@@ -95,11 +95,13 @@ def handle_failed_results(choice)
orig_engine = instance_variable_get("@#{choice}")
orig_results = @results[orig_engine]
+
# record the error
Error.create(
:engine => orig_engine,
:error_info => orig_results.error.to_hash,
- :backtrace => orig_results.error[:exception].try(:backtrace)
+ :backtrace => orig_results.error[:exception].try(:backtrace),
+ :query => params[:q]
)
View
2 app/models/error.rb
@@ -1,5 +1,5 @@
class Error < ActiveRecord::Base
serialize :error_info
serialize :backtrace
- attr_accessible :backtrace, :engine, :error_info
+ attr_accessible :backtrace, :engine, :error_info, :query
end
View
5 db/migrate/20120912211133_add_query_to_errors.rb
@@ -0,0 +1,5 @@
+class AddQueryToErrors < ActiveRecord::Migration
+ def change
+ add_column :errors, :query, :string
+ end
+end
View
3 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120801211921) do
+ActiveRecord::Schema.define(:version => 20120912211133) do
create_table "errors", :force => true do |t|
t.string "engine"
@@ -19,6 +19,7 @@
t.text "error_info"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.string "query"
end
create_table "selections", :force => true do |t|
View
1 test/functional/battle_controller_test.rb
@@ -81,6 +81,7 @@ def choices
# proper error was saved
err = Error.last
assert_equal "error", err.engine
+ assert_equal "Cancer", err.query
# didn't use error, replaced it with next in list, BB

0 comments on commit ac6269a

Please sign in to comment.
Something went wrong with that request. Please try again.