Sha256: dc7d81791f323237acb7cd3050618960de98274d508bee551745011a2260652e

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 KB

Contents

module Faye
  class Error
    
    def self.parse(string)
      return nil unless Grammar::ERROR =~ string
      parts = string.split(':')
      args  = parts[1].split(',')
      new(parts[0].to_i, args, parts[2])
    end
    
    def self.method_missing(type, *args)
      code = const_get(type.to_s.upcase)
      new(code[0], args, code[1]).to_s
    end
    
    attr_reader :code, :args, :message
    
    def initialize(code, args, message)
      @code     = code
      @args     = args
      @message  = message
    end
    
    def to_s
      "#{ @code }:#{ @args * ',' }:#{ @message }"
    end
    
    # http://code.google.com/p/cometd/wiki/BayeuxCodes
    VERSION_MISMATCH    = [300, 'Version mismatch']
    CONNTYPE_MISMATCH   = [301, 'Connection types not supported']
    EXT_MISMATCH        = [302, 'Extension mismatch']
    BAD_REQUEST         = [400, 'Bad request']
    CLIENT_UNKNOWN      = [401, 'Unknown client']
    PARAMETER_MISSING   = [402, 'Missing required parameter']
    CHANNEL_FORBIDDEN   = [403, 'Forbidden channel']
    CHANNEL_UNKNOWN     = [404, 'Unknown channel']
    CHANNEL_INVALID     = [405, 'Invalid channel']
    EXT_UNKNOWN         = [406, 'Unknown extension']
    PUBLISH_FAILED      = [407, 'Failed to publish']
    SERVER_ERROR        = [500, 'Internal server error']
    
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
goshrine_bot-0.1.1 lib/goshrine_bot/faye/error.rb
goshrine_bot-0.1.0 lib/goshrine_bot/faye/error.rb
faye-0.3.4 lib/faye/error.rb
faye-0.3.3 lib/faye/error.rb
faye-0.3.2 lib/faye/error.rb
faye-0.3.1 lib/faye/error.rb
faye-0.3.0 lib/faye/error.rb
faye-0.2.2 lib/faye/error.rb
faye-0.1.0 lib/faye/error.rb
faye-0.1.1 lib/faye/error.rb