lib/http/2/error.rb in http-2-0.12.0 vs lib/http/2/error.rb in http-2-1.0.0
- old
+ new
@@ -1,12 +1,29 @@
# frozen_string_literal: true
module HTTP2
# Stream, connection, and compressor exceptions.
module Error
- class Error < StandardError; end
+ @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
@@ -40,7 +57,11 @@
# 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