Sha256: ec35439e1e6dadab7d475c535e751996b634d9a9b3f197574a0c8003b5bf551f
Contents?: true
Size: 889 Bytes
Versions: 63
Compression:
Stored size: 889 Bytes
Contents
module Vagrant module Util # This module provides a `safe_puts` method which outputs to # the given IO object, and rescues any broken pipe errors and # ignores them. This is useful in cases where you're outputting # to stdout, for example, and the stdout is closed, but you want to # keep running. module SafePuts # Uses `puts` on the given IO object and safely ignores any # Errno::EPIPE. # # @param [String] message Message to output. # @param [Hash] opts Options hash. def safe_puts(message=nil, opts=nil) message ||= "" opts = { io: $stdout, printer: :puts }.merge(opts || {}) begin opts[:io].send(opts[:printer], message) rescue Errno::EPIPE # This is what makes this a `safe` puts. return end end end end end
Version data entries
63 entries across 56 versions & 8 rubygems