class DTK::Client::DtkError
Attributes
backtrace[R]
Public Class Methods
new(msg,opts={})
click to toggle source
Calls superclass method
# File lib/dtk_error.rb, line 21 def initialize(msg,opts={}) super(msg) @backtrace = opts[:backtrace] end
raise_error(response)
click to toggle source
# File lib/dtk_error.rb, line 27 def self.raise_error(response) raise_if_error?(response,:default_error_if_nil => true) end
raise_if_error?(response,opts={})
click to toggle source
# File lib/dtk_error.rb, line 30 def self.raise_if_error?(response,opts={}) # check for errors in response unless error = response.error_info?(opts) return end # if error_internal.first == true case error.code when :unauthorized raise self, "[UNAUTHORIZED] Your session has been suspended, please log in again." when :session_timeout raise self, "[SESSION TIMEOUT] Your session has been suspended, please log in again." when :broken raise self, "[BROKEN] Unable to connect to the DTK server at host: #{Config[:server_host]}" when :forbidden raise DTK::Client::DtkLoginRequiredError, "[FORBIDDEN] Access not granted, please log in again." when :timeout raise self, "[TIMEOUT ERROR] Server is taking too long to respond." when :connection_refused raise self, "[CONNECTION REFUSED] Connection refused by server." when :resource_not_found raise self, "[RESOURCE NOT FOUND] #{error.msg}" when :pg_error raise self, "[PG_ERROR] #{error.msg}" when :server_error raise Server.new(error.msg,:backtrace => error.backtrace) when :client_error raise Client.new(error.msg,:backtrace => error.backtrace) else # if usage error occurred, display message to console and display that same message to log raise Usage.new(error.msg) end end