Class: Kcaco::WrappedException

Inherits:
Object
  • Object
show all
Defined in:
lib/kcaco/wrapped_exception.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ WrappedException

Returns a new instance of WrappedException.



9
10
11
# File 'lib/kcaco/wrapped_exception.rb', line 9

def initialize(exception)
  self.exception = exception
end

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception.



7
8
9
# File 'lib/kcaco/wrapped_exception.rb', line 7

def exception
  @exception
end

#payloadObject

Returns the value of attribute payload.



7
8
9
# File 'lib/kcaco/wrapped_exception.rb', line 7

def payload
  @payload
end

Instance Method Details

#backtraceObject



22
23
24
# File 'lib/kcaco/wrapped_exception.rb', line 22

def backtrace
  exception.backtrace
end

#extract_filename_and_line_no(line) ⇒ Object



30
31
32
33
34
# File 'lib/kcaco/wrapped_exception.rb', line 30

def extract_filename_and_line_no(line)
  if (m = line.match(/(.+):(\d+):/))
    [File.basename(m[1]), m[2].to_i]
  end
end

#filenameObject



41
42
43
# File 'lib/kcaco/wrapped_exception.rb', line 41

def filename
  filename_and_line_no.first
end

#filename_and_line_noObject



36
37
38
39
# File 'lib/kcaco/wrapped_exception.rb', line 36

def filename_and_line_no
  @filename_and_line_no ||= 
    extract_filename_and_line_no(backtrace.first)
end

#line_noObject



45
46
47
# File 'lib/kcaco/wrapped_exception.rb', line 45

def line_no
  filename_and_line_no.last
end

#messageObject



18
19
20
# File 'lib/kcaco/wrapped_exception.rb', line 18

def message
  exception.message
end

#prettyObject



53
54
55
56
57
58
59
# File 'lib/kcaco/wrapped_exception.rb', line 53

def pretty
  [
   uuid,
   title,
   "[%s L%i]" % [filename, line_no],
  ].join(" ")
end

#titleObject



49
50
51
# File 'lib/kcaco/wrapped_exception.rb', line 49

def title
  [type, message].join(": ")
end

#to_yamlObject



26
27
28
# File 'lib/kcaco/wrapped_exception.rb', line 26

def to_yaml
  exception.to_yaml
end

#typeObject



14
15
16
# File 'lib/kcaco/wrapped_exception.rb', line 14

def type
  exception.class.name
end

#uuidObject



61
62
63
# File 'lib/kcaco/wrapped_exception.rb', line 61

def uuid
  @uuid ||= Guid.new.to_s
end