Class: Kcaco::FileWriter
- Inherits:
-
Object
- Object
- Kcaco::FileWriter
- Defined in:
- lib/kcaco/file_writer.rb
Instance Attribute Summary collapse
-
#exception ⇒ Object
Returns the value of attribute exception.
Instance Method Summary collapse
-
#initialize(exception) ⇒ FileWriter
constructor
A new instance of FileWriter.
- #save(path) ⇒ Object
Constructor Details
#initialize(exception) ⇒ FileWriter
Returns a new instance of FileWriter.
11 12 13 |
# File 'lib/kcaco/file_writer.rb', line 11 def initialize(exception) self.exception = exception end |
Instance Attribute Details
#exception ⇒ Object
Returns the value of attribute exception.
9 10 11 |
# File 'lib/kcaco/file_writer.rb', line 9 def exception @exception end |
Instance Method Details
#save(path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kcaco/file_writer.rb', line 16 def save(path) FileUtils.mkdir_p(File.dirname(path)) File.open(path, "w") do |f| [ ["time", Time.now.iso8601], ["type", exception.type], ["message", exception.], ["payload", exception.payload], ].each do |label, text| f.puts([label, text].join(": ")) end f.puts("backtrace:") exception.backtrace.each do |line| f.puts(line) end f.puts f.puts(exception.to_yaml) end end |