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
-
#check_errors(raw: false) ⇒ Object
Check if there were errors in previous commands.
Instance Method Details
#check_errors(raw: false) ⇒ Object
Check if there were errors in previous commands. Throws GnuplotError in case of any errors.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gnuplotrb/mixins/error_handling.rb', line 14 def check_errors(raw: false) return if @err_array.empty? command = '' rest = '' @semaphore.synchronize do command = @err_array.first rest = @err_array[1..-1].join('; ') @err_array.clear end = if raw "#{command};#{rest}}" else "Error in previous command (\"#{command}\"): \"#{rest}\"" end fail GnuplotError, end |