Exception: Exempi::ExempiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/exempi/exceptions.rb

Overview

This class provides a convenient interface for throwing exceptions when using Exempi functions. It allows the caller to specify an error code (retrievable from xmp_get_error()), and provides a method to retrieve the error name based on the code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_code = 0) ⇒ ExempiError

Returns a new instance of ExempiError.



10
11
12
13
14
15
# File 'lib/exempi/exceptions.rb', line 10

def initialize error_code=0
  if !Exempi::ErrorCodes[error_code]
    raise ArgumentError, "#{error_code} is not an Exempi error code"
  end
  @error_code = error_code
end

Instance Attribute Details

#error_codeObject (readonly)

Returns the value of attribute error_code.



9
10
11
# File 'lib/exempi/exceptions.rb', line 9

def error_code
  @error_code
end

Instance Method Details

#xmp_errorSymbol

Returns Exempi’s error string for this exception.

Returns:

  • (Symbol)

    Exempi’s error string for this exception



18
19
20
# File 'lib/exempi/exceptions.rb', line 18

def xmp_error
  Exempi::ErrorCodes[@error_code]
end