Exception: DTK::Client::DtkError
Direct Known Subclasses
Defined Under Namespace
Classes: Client, InteractiveWizardError, InternalError, Server, Usage
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(msg, opts = {}) ⇒ DtkError
constructor
A new instance of DtkError.
Constructor Details
#initialize(msg, opts = {}) ⇒ DtkError
Returns a new instance of DtkError.
21 22 23 24 |
# File 'lib/dtk_error.rb', line 21 def initialize(msg,opts={}) super(msg) @backtrace = opts[:backtrace] end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
25 26 27 |
# File 'lib/dtk_error.rb', line 25 def backtrace @backtrace end |
Class Method Details
.raise_error(response) ⇒ Object
27 28 29 |
# 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 = {}) ⇒ Boolean
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 |
# 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 |