mirror of
https://github.com/vidarh/ruby-x11
synced 2024-12-27 09:59:21 +01:00
inherit custom errors from StandardError
This commit is contained in:
parent
910924a36d
commit
5663788eb8
2 changed files with 11 additions and 19 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
module X11
|
||||||
|
class X11Error < StandardError; end
|
||||||
|
end
|
||||||
|
|
||||||
require 'socket'
|
require 'socket'
|
||||||
require 'active_support'
|
require 'active_support'
|
||||||
require 'hexdump'
|
require 'hexdump'
|
||||||
|
@ -6,8 +10,3 @@ require 'X11/auth'
|
||||||
require 'X11/display'
|
require 'X11/display'
|
||||||
require 'X11/encode'
|
require 'X11/encode'
|
||||||
require 'X11/packet'
|
require 'X11/packet'
|
||||||
|
|
||||||
module X11
|
|
||||||
class X11Error < StandardError; end
|
|
||||||
class X11Exception < RuntimeException; end
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,15 +1,8 @@
|
||||||
module X11
|
module X11
|
||||||
|
|
||||||
class DisplayException < X11Exception; end
|
class DisplayError < X11Error; end
|
||||||
class ConnectionException < DisplayException; end
|
class ConnectionError < DisplayError; end
|
||||||
|
class AuthorizationError < ConnectionError; end
|
||||||
class AuthorizationException < ConnectionException
|
|
||||||
attr_reader :errorcode
|
|
||||||
def initialize msg, errcode=nil
|
|
||||||
super msg
|
|
||||||
@errorcode = errcode
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Display
|
class Display
|
||||||
|
|
||||||
|
@ -53,14 +46,14 @@ private
|
||||||
when X11::Auth::FAILED
|
when X11::Auth::FAILED
|
||||||
len, major, minor, xlen = @socket.read(7).unpack("CSSS")
|
len, major, minor, xlen = @socket.read(7).unpack("CSSS")
|
||||||
reason = @socket.read(xlen * 4)
|
reason = @socket.read(xlen * 4)
|
||||||
reason = reason[0..len]
|
reason = reason[0..len]
|
||||||
raise AuthorizationException.new "Connection to server failed -- (version #{major}.#{minor}) #{reason}", X11::Auth::FAILED
|
raise AuthorizationError, "Connection to server failed -- (version #{major}.#{minor}) #{reason}"
|
||||||
when X11::Auth::AUTHENTICATE
|
when X11::Auth::AUTHENTICATE
|
||||||
raise AuthorizationException.new "Connection requires authentication", X11::Auth::AUTHENTICATE
|
raise AuthorizationError, "Connection requires authentication"
|
||||||
when X11::Auth::SUCCESS
|
when X11::Auth::SUCCESS
|
||||||
puts "CONNECTION SUCCESS"
|
puts "CONNECTION SUCCESS"
|
||||||
else
|
else
|
||||||
raise AuthorizationException.new "Received unknown opcode #{type}"
|
raise AuthorizationError, "Received unknown opcode #{type}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue