Exception: Rmega::RequestError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rmega/request_error.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_code) ⇒ RequestError

Returns a new instance of RequestError.



3
4
5
6
# File 'lib/rmega/request_error.rb', line 3

def initialize(error_code)
  message = self.class.errors[error_code]
  super("Error #{error_code}: #{message}")
end

Class Method Details

.error_code?(number) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/rmega/request_error.rb', line 8

def self.error_code?(number)
  number.respond_to?(:to_i) and number.to_i < 0
end

.errorsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rmega/request_error.rb', line 12

def self.errors
  {
    -1  => 'An internal error has occurred. Please submit a bug report, detailing the exact circumstances in which this error occurred.',
    -2  => 'You have passed invalid arguments to this command.',
    -3  => 'A temporary congestion or server malfunction prevented your request from being processed. No data was altered. Retry. Retries must be spaced with exponential backoff.',
    -4  => 'You have exceeded your command weight per time quota. Please wait a few seconds, then try again (this should never happen in sane real-life applications).',
    -5  => 'The upload failed. Please restart it from scratch.',
    -6  => 'Too many concurrent IP addresses are accessing this upload target URL.',
    -7  => 'The upload file packet is out of range or not starting and ending on a chunk boundary.',
    -8  => 'The upload target URL you are trying to access has expired. Please request a fresh one.',
    -9  => 'Object (typically, node or user) not found',
    -10 => 'Circular linkage attempted',
    -11 => 'Access violation (e.g., trying to write to a read-only share)',
    -12 => 'Trying to create an object that already exists',
    -13 => 'Trying to access an incomplete resource',
    -14 => 'A decryption operation failed (never returned by the API)',
    -15 => 'Invalid or expired user session, please relogin',
    -16 => 'User blocked',
    -17 => 'Request over quota',
    -18 => 'Resource temporarily not available, please try again later'
  }
end