Class: DatabaseConsistency::RescueError

Inherits:
Object
  • Object
show all
Defined in:
lib/database_consistency/rescue_error.rb

Overview

The class writes error to the file

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRescueError

Returns a new instance of RescueError.



18
19
20
21
22
23
# File 'lib/database_consistency/rescue_error.rb', line 18

def initialize
  puts 'Hey, some checks fail with an error, please open an issue on github at https://github.com/djezzzl/database_consistency.'
  puts "Attach the created file: #{filename}"
  puts 'Thank you, for your contribution!'
  puts '(c) Evgeniy Demin <[email protected]>'
end

Class Method Details

.call(error) ⇒ Object



8
9
10
11
# File 'lib/database_consistency/rescue_error.rb', line 8

def self.call(error)
  @singleton ||= new
  @singleton.call(error)
end

.empty?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/database_consistency/rescue_error.rb', line 14

def self.empty?
  @singleton.nil?
end

Instance Method Details

#call(error) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/database_consistency/rescue_error.rb', line 25

def call(error)
  File.open(filename, 'a') do |file|
    file.puts('<===begin===>')
    file.puts('Metadata:')
    DebugContext.output(file)
    file.puts('Stack trace:')
    file.puts(error.full_message)
    file.puts('<===end===>')
  end
end