Class: MysqlPause::Error
- Inherits:
-
Object
- Object
- MysqlPause::Error
- Defined in:
- lib/mysql-pause/error.rb
Constant Summary collapse
- ERROR_HEADER =
'%MYSQL_PAUSE%'- ERROR_SEPARATOR =
';;'- ERROR_LIST =
{}
Class Method Summary collapse
Class Method Details
.create_error_message(error_code, sequence_id) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mysql-pause/error.rb', line 9 def (error_code, sequence_id) # fetch error info mysql_error_code, sql_state, = ERROR_LIST[error_code] # create mysql error message = [ERROR_HEADER, error_code, ].join(ERROR_SEPARATOR) # create header mysql_error_code = convert_to_chars(mysql_error_code, 2) payload = ["\xFF", mysql_error_code, '#', sql_state, ].join payload_length = convert_to_chars(payload.length, 3) sequence_id = convert_to_chars(sequence_id, 1) [payload_length, sequence_id, payload].join end |
.mysql_pause_error?(e) ⇒ Boolean
25 26 27 |
# File 'lib/mysql-pause/error.rb', line 25 def mysql_pause_error?(e) /#{Regexp.escape(ERROR_HEADER)}/ =~ e. end |