diff --git a/lib/X11.rb b/lib/X11.rb index 283a172..522c76c 100644 --- a/lib/X11.rb +++ b/lib/X11.rb @@ -1,3 +1,7 @@ +module X11 + class X11Error < StandardError; end +end + require 'socket' require 'active_support' require 'hexdump' @@ -6,8 +10,3 @@ require 'X11/auth' require 'X11/display' require 'X11/encode' require 'X11/packet' - -module X11 - class X11Error < StandardError; end - class X11Exception < RuntimeException; end -end diff --git a/lib/X11/display.rb b/lib/X11/display.rb index 4b13f73..af826cd 100644 --- a/lib/X11/display.rb +++ b/lib/X11/display.rb @@ -1,15 +1,8 @@ module X11 - class DisplayException < X11Exception; end - class ConnectionException < DisplayException; end - - class AuthorizationException < ConnectionException - attr_reader :errorcode - def initialize msg, errcode=nil - super msg - @errorcode = errcode - end - end + class DisplayError < X11Error; end + class ConnectionError < DisplayError; end + class AuthorizationError < ConnectionError; end class Display @@ -53,14 +46,14 @@ private when X11::Auth::FAILED len, major, minor, xlen = @socket.read(7).unpack("CSSS") reason = @socket.read(xlen * 4) - reason = reason[0..len] - raise AuthorizationException.new "Connection to server failed -- (version #{major}.#{minor}) #{reason}", X11::Auth::FAILED + reason = reason[0..len] + raise AuthorizationError, "Connection to server failed -- (version #{major}.#{minor}) #{reason}" when X11::Auth::AUTHENTICATE - raise AuthorizationException.new "Connection requires authentication", X11::Auth::AUTHENTICATE + raise AuthorizationError, "Connection requires authentication" when X11::Auth::SUCCESS puts "CONNECTION SUCCESS" else - raise AuthorizationException.new "Received unknown opcode #{type}" + raise AuthorizationError, "Received unknown opcode #{type}" end end