Exception: MysqlPR::Error
- Inherits:
-
StandardError
- Object
- StandardError
- MysqlPR::Error
- Defined in:
- lib/mysql-pr/error.rb
Direct Known Subclasses
Constant Summary collapse
- ERRNO =
0
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#sqlstate ⇒ Object
readonly
Returns the value of attribute sqlstate.
Class Method Summary collapse
Instance Method Summary collapse
- #errno ⇒ Object
-
#initialize(message, sqlstate = "HY000") ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message, sqlstate = "HY000") ⇒ Error
Returns a new instance of Error.
27 28 29 30 31 |
# File 'lib/mysql-pr/error.rb', line 27 def initialize(, sqlstate = "HY000") @sqlstate = sqlstate @error = super end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
25 26 27 |
# File 'lib/mysql-pr/error.rb', line 25 def error @error end |
#sqlstate ⇒ Object (readonly)
Returns the value of attribute sqlstate.
25 26 27 |
# File 'lib/mysql-pr/error.rb', line 25 def sqlstate @sqlstate end |
Class Method Details
.define_error_class(prefix_re) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mysql-pr/error.rb', line 10 def self.define_error_class(prefix_re) constants.each do |errname| errname = errname.to_s next unless errname =~ prefix_re errno = const_get errname excname = errname.sub(prefix_re, "").gsub(/(\A.|_.)([A-Z]+)/) { ::Regexp.last_match(1) + ::Regexp.last_match(2).downcase }.gsub(/_/, "") klass = Class.new self klass.const_set "ERRNO", errno const_set excname, klass self::ERROR_MAP[errno] = klass MysqlPR::Error.const_set errname, errno end end |
Instance Method Details
#errno ⇒ Object
33 34 35 |
# File 'lib/mysql-pr/error.rb', line 33 def errno self.class::ERRNO end |