1 2 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
# frozen_string_literal: true
module HTTP2
# Stream, connection, and compressor exceptions.
module Error
@types = {}
class << self
attr_reader :types
end
class Error < StandardError
def self.inherited(klass)
super
type = klass.name or return
type = type.split("::").last or return
type = type.gsub(/([^\^])([A-Z])/, '\1_\2').downcase.to_sym
HTTP2::Error.types[type] = klass
end
end
# Raised if connection header is missing or invalid indicating that
# this is an invalid HTTP 2.0 request - no frames are emitted and the
# connection must be aborted.
class HandshakeError < Error; end
# Raised by stream or connection handlers, results in GOAWAY frame
# which signals termination of the current connection. You *cannot*
# recover from this exception, or any exceptions subclassed from it.
class ProtocolError < Error; end
# Raised on any header encoding / decoding exception.
#
# @see ProtocolError
class CompressionError < ProtocolError; end
# Raised on invalid flow control frame or command.
#
# @see ProtocolError
class FlowControlError < ProtocolError; end
# Raised on invalid stream processing: invalid frame type received or
# sent, or invalid command issued.
class InternalError < ProtocolError; end
#
# -- Recoverable errors -------------------------------------------------
#
# Raised if stream has been closed and new frames cannot be sent.
class StreamClosed < Error; end
# Raised if connection has been closed (or draining) and new stream
# cannot be opened.
class ConnectionClosed < Error; end
# Raised if stream limit has been reached and new stream cannot be opened.
class StreamLimitExceeded < Error; end
class FrameSizeError < Error; end
@types.freeze
end
end
|