Class: Clt::ErrorMessage

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

Class Method Summary collapse

Class Method Details

.raise_error(params) ⇒ Object

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/clt/error_message.rb', line 3

def self.raise_error(params)
  message = nil

  case params[:msg]
  when :missing_parameter
    message = "Missing required parameter: #{params[:field]}"
  when :parameter_should_be
    message = "#{params[:field]} should be #{params[:data]}"
  when :data_length_too_short
    message = "The length of #{params[:field]} is too short"
  when :wrong_data_format
    message = "The format of #{params[:field]} is wrong"
  when :cannot_be_empty
    message = "#{params[:field]} cannot be empty"
  end

  raise ArgumentError, message
end