Sha256: 8a13906345e5e2acee601bc4bffeff6068bcc5af615cee5306f733f49fae0f7a

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

class ParseError
  
  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
  
  def to_array
    @error[1] = @error[1] + " " + @msg
    @error
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parse_resource-1.7.3 lib/parse_resource/parse_error.rb
parse_resource-1.7.2 lib/parse_resource/parse_error.rb