lib/active_storage/previewer.rb in activestorage-6.1.3.2 vs lib/active_storage/previewer.rb in activestorage-6.1.4
- old
+ new
@@ -68,10 +68,19 @@
ActiveSupport::Notifications.instrument "#{operation}.active_storage", payload, &block
end
def capture(*argv, to:)
to.binmode
- IO.popen(argv, err: File::NULL) { |out| IO.copy_stream(out, to) }
+
+ open_tempfile do |err|
+ IO.popen(argv, err: err) { |out| IO.copy_stream(out, to) }
+ err.rewind
+
+ unless $?.success?
+ raise PreviewError, "#{argv.first} failed (status #{$?.exitstatus}): #{err.read.to_s.chomp}"
+ end
+ end
+
to.rewind
end
def logger #:doc:
ActiveStorage.logger