Module: Rea::ErrorUtils

Included in:
DBLP, DBLP::Parser
Defined in:
lib/rea/errors.rb

Instance Method Summary collapse

Instance Method Details

#error_message(msg, source = nil, cause = $!) ⇒ Object



25
26
27
28
29
30
# File 'lib/rea/errors.rb', line 25

def error_message(msg, source = nil, cause = $!)
  msg = msg.dup
  msg << " #{source}" if source
  msg << ", #{cause.message}" if cause
  msg
end

#not_found_error!(source) ⇒ Object

Raises:



42
43
44
45
# File 'lib/rea/errors.rb', line 42

def not_found_error!(source)
  msg = error_message("Unable to find", source)
  raise Rea::NotFoundError, msg
end

#not_implemented_error!(msg) ⇒ Object



52
53
54
# File 'lib/rea/errors.rb', line 52

def not_implemented_error!(msg)
  raise Rea::NotImplementedError, msg
end

#parse_error!(source) ⇒ Object

Raises:



32
33
34
35
# File 'lib/rea/errors.rb', line 32

def parse_error!(source)
  msg = error_message("Error while parsing", source)
  raise Rea::ParseError, msg
end

#parse_format_error!(source) ⇒ Object



47
48
49
50
# File 'lib/rea/errors.rb', line 47

def parse_format_error!(source)
  msg = error_message("Unexpected parsing error (#{source})")
  raise Rea::ParseFormatError, msg
end

#third_party_error!(source) ⇒ Object



37
38
39
40
# File 'lib/rea/errors.rb', line 37

def third_party_error!(source)
  msg = error_message("Error with third party service", source)
  raise Rea::ThirdPartyError, msg
end

#unexpected_error!(source) ⇒ Object

Raises:



56
57
58
59
# File 'lib/rea/errors.rb', line 56

def unexpected_error!(source)
  msg = error_message("Unexpected error (#{source})")
  raise Rea::SystemError, msg
end