From 795b9de3e40bbe4ceebc7386bc1ced166d096725 Mon Sep 17 00:00:00 2001 From: Jared Pace Date: Thu, 5 Aug 2010 22:47:59 -0500 Subject: [PATCH] Display full info on Errs#show page --- app/helpers/hash_helper.rb | 20 ++++++++++++++++++++ app/models/err.rb | 2 +- app/models/notice.rb | 19 +++++++++++++++++++ app/views/errs/show.html.haml | 16 ++++++++++++++-- app/views/notices/_backtrace.html.haml | 4 ++-- app/views/notices/_environment.html.haml | 6 ++++++ app/views/notices/_params.html.haml | 3 +++ app/views/notices/_session.html.haml | 2 ++ app/views/notices/_summary.html.haml | 13 +++++++++++++ public/stylesheets/application.css | 18 +++++++++++------- 10 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 app/helpers/hash_helper.rb create mode 100644 app/views/notices/_environment.html.haml create mode 100644 app/views/notices/_params.html.haml create mode 100644 app/views/notices/_session.html.haml create mode 100644 app/views/notices/_summary.html.haml diff --git a/app/helpers/hash_helper.rb b/app/helpers/hash_helper.rb new file mode 100644 index 0000000..7681a89 --- /dev/null +++ b/app/helpers/hash_helper.rb @@ -0,0 +1,20 @@ +module HashHelper + + def pretty_hash(hash, nesting = 0) + tab_size = 2 + nesting += 1 + + pretty = "{" + sorted_keys = hash.keys.sort + sorted_keys.each do |key| + val = hash[key].is_a?(Hash) ? pretty_hash(hash[key], nesting) : hash[key].inspect + pretty += "\n#{' '*nesting*tab_size}" + pretty += "#{key.inspect} => #{val}" + pretty += "," unless key == sorted_keys.last + + end + nesting -= 1 + pretty += "\n#{' '*nesting*tab_size}}" + end + +end \ No newline at end of file diff --git a/app/models/err.rb b/app/models/err.rb index 25efefa..b622a99 100644 --- a/app/models/err.rb +++ b/app/models/err.rb @@ -35,7 +35,7 @@ class Err end def where - where = component + where = component.dup where << "##{action}" if action.present? where end diff --git a/app/models/notice.rb b/app/models/notice.rb index 1d1b09a..f731c6c 100644 --- a/app/models/notice.rb +++ b/app/models/notice.rb @@ -19,6 +19,9 @@ class Notice hoptoad_notice = Hoptoad::V2.parse_xml(hoptoad_xml) project = Project.find_by_api_key!(hoptoad_notice['api-key']) + hoptoad_notice['request']['component'] = 'unknown' if hoptoad_notice['request']['component'].blank? + hoptoad_notice['request']['action'] = nil if hoptoad_notice['request']['action'].blank? + error = Err.for({ :project => project, :klass => hoptoad_notice['error']['class'], @@ -36,6 +39,22 @@ class Notice }) end + def request + read_attribute(:request) || {} + end + + def env_vars + request['cgi-data'] || {} + end + + def params + request['params'] || {} + end + + def session + request['session'] || {} + end + def deliver_notification Mailer.error_notification(self).deliver end diff --git a/app/views/errs/show.html.haml b/app/views/errs/show.html.haml index 3273673..d8de650 100644 --- a/app/views/errs/show.html.haml +++ b/app/views/errs/show.html.haml @@ -14,6 +14,18 @@ = link_to "back to '#{@project.name}'", project_path(@project) | = link_to 'resolve', '#' if @err.unresolved? - + +%h3#summary Summary += render 'notices/summary', :notice => @notice + %h3#backtrace Backtrace -= render 'notices/backtrace', :lines => @notice.backtrace \ No newline at end of file += render 'notices/backtrace', :lines => @notice.backtrace + +%h3#environment Environment += render 'notices/environment', :notice => @notice + +%h3#params Parameters += render 'notices/params', :notice => @notice + +%h3#session Session += render 'notices/session', :notice => @notice \ No newline at end of file diff --git a/app/views/notices/_backtrace.html.haml b/app/views/notices/_backtrace.html.haml index f8c8f3c..953f6b5 100644 --- a/app/views/notices/_backtrace.html.haml +++ b/app/views/notices/_backtrace.html.haml @@ -1,5 +1,5 @@ -.backtrace - %table +.window + %table.backtrace %tr %th %ul.line-numbers diff --git a/app/views/notices/_environment.html.haml b/app/views/notices/_environment.html.haml new file mode 100644 index 0000000..ebf533e --- /dev/null +++ b/app/views/notices/_environment.html.haml @@ -0,0 +1,6 @@ +.window + %table.environment + - notice.env_vars.each do |key,val| + %tr + %th= key + %td.main= val \ No newline at end of file diff --git a/app/views/notices/_params.html.haml b/app/views/notices/_params.html.haml new file mode 100644 index 0000000..5f59262 --- /dev/null +++ b/app/views/notices/_params.html.haml @@ -0,0 +1,3 @@ +.window + %pre.hash= pretty_hash notice.params + \ No newline at end of file diff --git a/app/views/notices/_session.html.haml b/app/views/notices/_session.html.haml new file mode 100644 index 0000000..27a905c --- /dev/null +++ b/app/views/notices/_session.html.haml @@ -0,0 +1,2 @@ +.window + %pre.hash= pretty_hash notice.session \ No newline at end of file diff --git a/app/views/notices/_summary.html.haml b/app/views/notices/_summary.html.haml new file mode 100644 index 0000000..c67f45e --- /dev/null +++ b/app/views/notices/_summary.html.haml @@ -0,0 +1,13 @@ +%table.summary + %tr + %th URL + %td.main= notice.request['url'] + %tr + %th Where + %td= notice.err.where + %tr + %th Occurred + %td= notice.created_at.to_s(:micro) + %tr + %th Similar + %td= notice.err.notices.count - 1 \ No newline at end of file diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index d3133bf..10cbd40 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -203,6 +203,9 @@ td.deploy { td.latest { white-space: nowrap; } +td.count { + text-align: right; +} /* Err Tables */ table.errs td.message a { @@ -214,30 +217,31 @@ table.errs td.message em { } /* Backtrace */ -.backtrace { +.window { width: 100%; + margin-bottom: 1em; overflow: auto; } -.backtrace table { +.window table { margin: 0; } -.backtrace td { +table.backtrace td { width: 100%; padding: 0; margin: 0; color: #A2A2A2; background-color: #222 !important; } -.backtrace ul.line-numbers li { +table.backtrace ul.line-numbers li { text-align: right; } -.backtrace ul.lines { +table.backtrace ul.lines { padding: 10px 8px; overflow: auto; } -.backtrace li { +table.backtrace li { white-space: nowrap; } -.backtrace li.in-project { +table.backtrace li.in-project { color: #2adb2e; } \ No newline at end of file -- libgit2 0.21.2