Exception: Mysql::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Mysql::Error
- Defined in:
- lib/mysql/error.rb
Overview
Mysql::Error
Direct Known Subclasses
Constant Summary collapse
- ERRNO =
0
Instance Attribute Summary collapse
-
#errno ⇒ Object
readonly
Returns the value of attribute errno.
-
#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
-
#initialize(message, sqlstate = 'HY000', errno = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message, sqlstate = 'HY000', errno = nil) ⇒ Error
Returns a new instance of Error.
28 29 30 31 32 33 |
# File 'lib/mysql/error.rb', line 28 def initialize(, sqlstate='HY000', errno=nil) @sqlstate = sqlstate @error = @errno = errno || self.class::ERRNO super end |
Instance Attribute Details
#errno ⇒ Object (readonly)
Returns the value of attribute errno.
26 27 28 |
# File 'lib/mysql/error.rb', line 26 def errno @errno end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
26 27 28 |
# File 'lib/mysql/error.rb', line 26 def error @error end |
#sqlstate ⇒ Object (readonly)
Returns the value of attribute sqlstate.
26 27 28 |
# File 'lib/mysql/error.rb', line 26 def sqlstate @sqlstate end |
Class Method Details
.define_error_class(prefix_re) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mysql/error.rb', line 12 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 |