Commit 795b9de3e40bbe4ceebc7386bc1ced166d096725

Authored by Jared Pace
1 parent 93030e53
Exists in master and in 1 other branch production

Display full info on Errs#show page

app/helpers/hash_helper.rb 0 → 100644
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
  1 +module HashHelper
  2 +
  3 + def pretty_hash(hash, nesting = 0)
  4 + tab_size = 2
  5 + nesting += 1
  6 +
  7 + pretty = "{"
  8 + sorted_keys = hash.keys.sort
  9 + sorted_keys.each do |key|
  10 + val = hash[key].is_a?(Hash) ? pretty_hash(hash[key], nesting) : hash[key].inspect
  11 + pretty += "\n#{' '*nesting*tab_size}"
  12 + pretty += "#{key.inspect} => #{val}"
  13 + pretty += "," unless key == sorted_keys.last
  14 +
  15 + end
  16 + nesting -= 1
  17 + pretty += "\n#{' '*nesting*tab_size}}"
  18 + end
  19 +
  20 +end
0 \ No newline at end of file 21 \ No newline at end of file
app/models/err.rb
@@ -35,7 +35,7 @@ class Err @@ -35,7 +35,7 @@ class Err
35 end 35 end
36 36
37 def where 37 def where
38 - where = component 38 + where = component.dup
39 where << "##{action}" if action.present? 39 where << "##{action}" if action.present?
40 where 40 where
41 end 41 end
app/models/notice.rb
@@ -19,6 +19,9 @@ class Notice @@ -19,6 +19,9 @@ class Notice
19 hoptoad_notice = Hoptoad::V2.parse_xml(hoptoad_xml) 19 hoptoad_notice = Hoptoad::V2.parse_xml(hoptoad_xml)
20 project = Project.find_by_api_key!(hoptoad_notice['api-key']) 20 project = Project.find_by_api_key!(hoptoad_notice['api-key'])
21 21
  22 + hoptoad_notice['request']['component'] = 'unknown' if hoptoad_notice['request']['component'].blank?
  23 + hoptoad_notice['request']['action'] = nil if hoptoad_notice['request']['action'].blank?
  24 +
22 error = Err.for({ 25 error = Err.for({
23 :project => project, 26 :project => project,
24 :klass => hoptoad_notice['error']['class'], 27 :klass => hoptoad_notice['error']['class'],
@@ -36,6 +39,22 @@ class Notice @@ -36,6 +39,22 @@ class Notice
36 }) 39 })
37 end 40 end
38 41
  42 + def request
  43 + read_attribute(:request) || {}
  44 + end
  45 +
  46 + def env_vars
  47 + request['cgi-data'] || {}
  48 + end
  49 +
  50 + def params
  51 + request['params'] || {}
  52 + end
  53 +
  54 + def session
  55 + request['session'] || {}
  56 + end
  57 +
39 def deliver_notification 58 def deliver_notification
40 Mailer.error_notification(self).deliver 59 Mailer.error_notification(self).deliver
41 end 60 end
app/views/errs/show.html.haml
@@ -14,6 +14,18 @@ @@ -14,6 +14,18 @@
14 = link_to "back to '#{@project.name}'", project_path(@project) 14 = link_to "back to '#{@project.name}'", project_path(@project)
15 | 15 |
16 = link_to 'resolve', '#' if @err.unresolved? 16 = link_to 'resolve', '#' if @err.unresolved?
17 - 17 +
  18 +%h3#summary Summary
  19 += render 'notices/summary', :notice => @notice
  20 +
18 %h3#backtrace Backtrace 21 %h3#backtrace Backtrace
19 -= render 'notices/backtrace', :lines => @notice.backtrace  
20 \ No newline at end of file 22 \ No newline at end of file
  23 += render 'notices/backtrace', :lines => @notice.backtrace
  24 +
  25 +%h3#environment Environment
  26 += render 'notices/environment', :notice => @notice
  27 +
  28 +%h3#params Parameters
  29 += render 'notices/params', :notice => @notice
  30 +
  31 +%h3#session Session
  32 += render 'notices/session', :notice => @notice
21 \ No newline at end of file 33 \ No newline at end of file
app/views/notices/_backtrace.html.haml
1 -.backtrace  
2 - %table 1 +.window
  2 + %table.backtrace
3 %tr 3 %tr
4 %th 4 %th
5 %ul.line-numbers 5 %ul.line-numbers
app/views/notices/_environment.html.haml 0 → 100644
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +.window
  2 + %table.environment
  3 + - notice.env_vars.each do |key,val|
  4 + %tr
  5 + %th= key
  6 + %td.main= val
0 \ No newline at end of file 7 \ No newline at end of file
app/views/notices/_params.html.haml 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +.window
  2 + %pre.hash= pretty_hash notice.params
  3 +
0 \ No newline at end of file 4 \ No newline at end of file
app/views/notices/_session.html.haml 0 → 100644
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
  1 +.window
  2 + %pre.hash= pretty_hash notice.session
0 \ No newline at end of file 3 \ No newline at end of file
app/views/notices/_summary.html.haml 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +%table.summary
  2 + %tr
  3 + %th URL
  4 + %td.main= notice.request['url']
  5 + %tr
  6 + %th Where
  7 + %td= notice.err.where
  8 + %tr
  9 + %th Occurred
  10 + %td= notice.created_at.to_s(:micro)
  11 + %tr
  12 + %th Similar
  13 + %td= notice.err.notices.count - 1
0 \ No newline at end of file 14 \ No newline at end of file
public/stylesheets/application.css
@@ -203,6 +203,9 @@ td.deploy { @@ -203,6 +203,9 @@ td.deploy {
203 td.latest { 203 td.latest {
204 white-space: nowrap; 204 white-space: nowrap;
205 } 205 }
  206 +td.count {
  207 + text-align: right;
  208 +}
206 209
207 /* Err Tables */ 210 /* Err Tables */
208 table.errs td.message a { 211 table.errs td.message a {
@@ -214,30 +217,31 @@ table.errs td.message em { @@ -214,30 +217,31 @@ table.errs td.message em {
214 } 217 }
215 218
216 /* Backtrace */ 219 /* Backtrace */
217 -.backtrace { 220 +.window {
218 width: 100%; 221 width: 100%;
  222 + margin-bottom: 1em;
219 overflow: auto; 223 overflow: auto;
220 } 224 }
221 -.backtrace table { 225 +.window table {
222 margin: 0; 226 margin: 0;
223 } 227 }
224 -.backtrace td { 228 +table.backtrace td {
225 width: 100%; 229 width: 100%;
226 padding: 0; 230 padding: 0;
227 margin: 0; 231 margin: 0;
228 color: #A2A2A2; 232 color: #A2A2A2;
229 background-color: #222 !important; 233 background-color: #222 !important;
230 } 234 }
231 -.backtrace ul.line-numbers li { 235 +table.backtrace ul.line-numbers li {
232 text-align: right; 236 text-align: right;
233 } 237 }
234 -.backtrace ul.lines { 238 +table.backtrace ul.lines {
235 padding: 10px 8px; 239 padding: 10px 8px;
236 overflow: auto; 240 overflow: auto;
237 } 241 }
238 -.backtrace li { 242 +table.backtrace li {
239 white-space: nowrap; 243 white-space: nowrap;
240 } 244 }
241 -.backtrace li.in-project { 245 +table.backtrace li.in-project {
242 color: #2adb2e; 246 color: #2adb2e;
243 } 247 }
244 \ No newline at end of file 248 \ No newline at end of file