Skip to content

Commit

Permalink
Added python error catching
Browse files Browse the repository at this point in the history
  • Loading branch information
shybovycha committed Feb 8, 2016
1 parent a21567d commit 0daa428
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/pygments/popen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ def mentos(method, args=[], kwargs={}, original_code=nil)
# mentos is now waiting for the header, and, potentially, code.
write_data(out_header, code)

check_for_error

# mentos will now return data to us. First it sends the header.
header = get_header

Expand All @@ -275,6 +277,16 @@ def mentos(method, args=[], kwargs={}, original_code=nil)
raise MentosError, "EPIPE"
end

def check_for_error
error_msg = @err.read

unless error_msg.empty?
@log.error "[#{Time.now.iso8601}] Error running python script: #{error_msg}"
stop "Error running python script: #{error_msg}"
raise MentosError, error_msg
end
end


# Based on the header we receive, determine if we need
# to read more bytes, and read those bytes if necessary.
Expand Down

0 comments on commit 0daa428

Please sign in to comment.