Class: Sneaql::Core::Commands::SneaqlOnError
- Inherits:
-
SneaqlCommand
- Object
- SneaqlCommand
- Sneaql::Core::Commands::SneaqlOnError
- Defined in:
- lib/sneaql_lib/core.rb
Overview
stores all the file paths matching the dir glob into a recordset
Instance Method Summary collapse
- #action(handler_action) ⇒ Object
-
#arg_definition ⇒ Object
argument types.
-
#replace_error_details(input_string) ⇒ String
replaces text ‘:err_message` and `:err_type` with appropriate values from the pending error.
-
#replace_last_record(input_string) ⇒ String
replaces a string with references to the field values in the last record iterated (if present).
- #rows_affected ⇒ Object
Methods inherited from SneaqlCommand
#initialize, #valid_expression?, #valid_operator?, #valid_recordset?, #valid_symbol?, #valid_variable?, #validate_args
Constructor Details
This class inherits a constructor from Sneaql::Core::SneaqlCommand
Instance Method Details
#action(handler_action) ⇒ Object
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
# File 'lib/sneaql_lib/core.rb', line 405 def action(handler_action) # only take action if there is an error if @exception_manager.pending_error case handler_action.downcase when 'continue' then @logger.error("#{@exception_manager.pending_error.}") if @exception_manager.pending_error.backtrace @exception_manager.pending_error.backtrace.each {|b| @logger.debug(b) } end @exception_manager.pending_error = nil @exception_manager.last_iterated_record = nil @logger.info("continuing after error due to on_error handling") when 'exit_step' then @logger.error("#{@exception_manager.pending_error.}") if @exception_manager.pending_error.backtrace @exception_manager.pending_error.backtrace.each {|b| @logger.debug(b) } end @exception_manager.pending_error = nil @exception_manager.last_iterated_record = nil @logger.info("exiting step due to on_error handling") raise Sneaql::Exceptions::SQLTestStepExitCondition when 'execute' then @logger.error("#{@exception_manager.pending_error.}") if @exception_manager.pending_error.backtrace @exception_manager.pending_error.backtrace.each {|b| @logger.debug(b) } end @logger.info("executing sql block due to on_error handling") @expression_handler.set_session_variable( 'last_statement_rows_affected', rows_affected ) @exception_manager.pending_error = nil @exception_manager.last_iterated_record = nil when 'fail' then @logger.error("#{@exception_manager.pending_error.}") if @exception_manager.pending_error.backtrace @exception_manager.pending_error.backtrace.each {|b| @logger.debug(b) } end @logger.info("exiting sneaql due to failure") raise Sneaql::Exceptions::ForceFailure end end end |
#arg_definition ⇒ Object
argument types
399 400 401 |
# File 'lib/sneaql_lib/core.rb', line 399 def arg_definition [:symbol] end |
#replace_error_details(input_string) ⇒ String
replaces text ‘:err_message` and `:err_type` with appropriate values from the pending error
489 490 491 492 493 494 495 496 497 498 499 |
# File 'lib/sneaql_lib/core.rb', line 489 def replace_error_details(input_string) tmp = input_string tmp = tmp.gsub( ':err_message', @exception_manager.pending_error..to_s ) tmp = tmp.gsub( ':err_type', @exception_manager.pending_error.class.to_s ) end |
#replace_last_record(input_string) ⇒ String
replaces a string with references to the field values in the last record iterated (if present). use :err_record.field_name syntax
471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/sneaql_lib/core.rb', line 471 def replace_last_record(input_string) tmp = input_string if @exception_manager.last_iterated_record != nil @exception_manager.last_iterated_record.keys.sort.reverse.each do |k| puts "replacing #{k}" tmp = tmp.gsub( ":err_record.#{k}", @exception_manager.last_iterated_record[k].to_s ) end end tmp end |
#rows_affected ⇒ Object
456 457 458 459 460 461 462 463 464 465 |
# File 'lib/sneaql_lib/core.rb', line 456 def rows_affected tmp = @statement tmp = replace_last_record(tmp) tmp = replace_error_details(tmp) JDBCHelpers::Execute.new( @jdbc_connection, tmp, @logger ).rows_affected end |