Sha256: ca7ed2e7a11677caad1055c1335012c323c1981a3a2c22b93bfb9efddfe766da

Contents?: true

Size: 1.39 KB

Versions: 23

Compression:

Stored size: 1.39 KB

Contents

module Faye
  class Error
    
    def self.method_missing(type, *args)
      code = const_get(type.to_s.upcase)
      new(code[0], args, code[1]).to_s
    end
    
    def self.parse(message)
      message ||= ''
      return new(nil, [], message) unless Grammar::ERROR =~ message

      parts   = message.split(':')
      code    = parts[0].to_i
      params  = parts[1].split(',')
      message = parts[2]

      new(code, params, message)
    end

    attr_reader :code, :params, :message
    
    def initialize(code, params, message)
      @code     = code
      @params   = params
      @message  = message
    end
    
    def to_s
      "#{ @code }:#{ @params * ',' }:#{ @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

23 entries across 23 versions & 3 rubygems

Version Path
faye-0.8.8 lib/faye/error.rb
faye-0.7.2 lib/faye/error.rb
faye-0.6.8 lib/faye/error.rb
faye-0.8.6 lib/faye/error.rb
faye-0.8.5 lib/faye/error.rb
faye-0.8.4 lib/faye/error.rb
faye-0.8.3 lib/faye/error.rb
faye-0.8.2 lib/faye/error.rb
_bushido-faye-0.8.2 lib/faye/error.rb
_bushido-faye-0.8.1 lib/faye/error.rb
bushido-faye-0.8.1 lib/faye/error.rb
faye-0.8.1 lib/faye/error.rb
faye-0.8.0 lib/faye/error.rb
faye-0.7.1 lib/faye/error.rb
faye-0.7.0 lib/faye/error.rb
faye-0.6.7 lib/faye/error.rb
faye-0.6.6 lib/faye/error.rb
faye-0.6.5 lib/faye/error.rb
faye-0.6.4 lib/faye/error.rb
faye-0.6.3 lib/faye/error.rb