Exception: Mysql::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Mysql::Error
- Defined in:
- lib/mysql/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.
25 26 27 28 29 |
# File 'lib/mysql/error.rb', line 25 def initialize(, sqlstate='HY000') @sqlstate = sqlstate @error = super end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
23 24 25 |
# File 'lib/mysql/error.rb', line 23 def error @error end |
#sqlstate ⇒ Object (readonly)
Returns the value of attribute sqlstate.
23 24 25 |
# File 'lib/mysql/error.rb', line 23 def sqlstate @sqlstate end |
Class Method Details
.define_error_class(prefix_re) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mysql/error.rb', line 9 def self.define_error_class(prefix_re) self.constants.each do |errname| errname = errname.to_s next unless errname =~ prefix_re errno = self.const_get errname excname = errname.sub(prefix_re,'').gsub(/(\A.|_.)([A-Z]+)/){$1+$2.downcase}.gsub(/_/,'') klass = Class.new self klass.const_set 'ERRNO', errno self.const_set excname, klass self::ERROR_MAP[errno] = klass Mysql::Error.const_set errname, errno end end |
Instance Method Details
#errno ⇒ Object
31 32 33 |
# File 'lib/mysql/error.rb', line 31 def errno self.class::ERRNO end |