Class: ParseError
- Inherits:
-
Object
- Object
- ParseError
- Defined in:
- lib/parse_error.rb
Instance Method Summary collapse
-
#initialize(code, msg = "") ⇒ ParseError
constructor
A new instance of ParseError.
- #to_array ⇒ Object
Constructor Details
#initialize(code, msg = "") ⇒ ParseError
Returns a new instance of ParseError.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/parse_error.rb', line 3 def initialize(code, msg="") @msg = msg case code when 202 @error = [:username, "must be unique"] when 111 @error = [:base, "field set to incorrect type. Error code #{code}. #{msg}"] when 125 @error = [:email, "must be valid"] when 122 @error = [:file_name, "contains only a-zA-Z0-9_. characters and is between 1 and 36 characters."] when 204 @error = [:email, "must not be missing"] when 203 @error = [:email, "has already been taken"] when 200 @error = [:username, "is missing or empty"] when 201 @error = [:password, "is missing or empty"] when 205 @error = [:user, "with specified email not found"] else raise "Parse error #{code}: #{@error}" end end |
Instance Method Details
#to_array ⇒ Object
29 30 31 |
# File 'lib/parse_error.rb', line 29 def to_array @error[1] = @error[1] + " " + @msg end |