Class: ErrorResponse

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

Constant Summary collapse

GEM_ROOT =
File.expand_path("../..", __FILE__)
YAML_PATH =
'lib/error_response.yml'

Class Method Summary collapse

Class Method Details

.call(key, message = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/error_response.rb', line 6

def self.call(key, message=nil)
  string_hash = YAML.load_file(File.join(GEM_ROOT,YAML_PATH))
  err_json = string_hash[key.to_s] || {'error_code' => 500000, 'error_message' => message}

  status = err_json['error_code'] / 1000
  {
    'status' => status,
    'json' => err_json
  }
end