Exception: Exempi::ExempiError
- Inherits:
-
StandardError
- Object
- StandardError
- Exempi::ExempiError
- 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
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
Instance Method Summary collapse
-
#initialize(error_code = 0) ⇒ ExempiError
constructor
A new instance of ExempiError.
-
#xmp_error ⇒ Symbol
Exempi’s error string for this exception.
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_code ⇒ Object (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_error ⇒ Symbol
Returns 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 |