Module: GnuplotRB::ErrorHandling

Included in:
Terminal
Defined in:
lib/gnuplotrb/mixins/error_handling.rb

Overview

Mixin for classes that need to run subprocess and handle errors from its stderr.

Instance Method Summary collapse

Instance Method Details

#check_errorsObject

Overview

Check if there were errors in previous commands. Throws GnuplotError in case of any errors.


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gnuplotrb/mixins/error_handling.rb', line 15

def check_errors
  return if @err_array.empty?
  command = ''
  rest = ''
  @semaphore.synchronize do
    command = @err_array.first
    rest = @err_array[1..-1].join('; ')
    @err_array.clear
  end
  message = "Error in previous command (\"#{command}\"): \"#{rest}\""
  fail GnuplotError, message
end