Exception: Skylight::NativeError
- Defined in:
- lib/skylight/errors.rb
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Class Method Summary collapse
- .code ⇒ Object
- .for_code(code) ⇒ Object
- .formatted_code ⇒ Object
- .message ⇒ Object
- .register(code, name, message) ⇒ Object
Instance Method Summary collapse
- #code ⇒ Object
- #formatted_code ⇒ Object
-
#initialize(method_name) ⇒ NativeError
constructor
A new instance of NativeError.
Constructor Details
#initialize(method_name) ⇒ NativeError
Returns a new instance of NativeError.
44 45 46 47 |
# File 'lib/skylight/errors.rb', line 44 def initialize(method_name) @method_name = method_name super(format("[E%<code>04d] %<message>s [%<meth>s]", code: code, message: self.class., meth: method_name)) end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
30 31 32 |
# File 'lib/skylight/errors.rb', line 30 def method_name @method_name end |
Class Method Details
.code ⇒ Object
32 33 34 |
# File 'lib/skylight/errors.rb', line 32 def self.code 9999 end |
.for_code(code) ⇒ Object
26 27 28 |
# File 'lib/skylight/errors.rb', line 26 def self.for_code(code) @classes[code] || self end |
.formatted_code ⇒ Object
36 37 38 |
# File 'lib/skylight/errors.rb', line 36 def self.formatted_code format("%<code>04d", code: code) end |
.message ⇒ Object
40 41 42 |
# File 'lib/skylight/errors.rb', line 40 def self. "Encountered an unknown internal error" end |
.register(code, name, message) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/skylight/errors.rb', line 11 def self.register(code, name, ) raise "Duplicate error class code: #{code}; name=#{name}" if @classes.key?(code) Skylight.module_eval <<-RUBY, __FILE__, __LINE__ + 1 class #{name}Error < NativeError # class SqlLexError < NativeError def self.code; #{code}; end # def self.code; 4; end def self.message; #{.to_json}; end # def self.message; "Failed to lex SQL query."; end end # end RUBY klass = Skylight.const_get("#{name}Error") @classes[code] = klass end |