Sha256: bed7721aa0326a9f2f2f5b3670f4d94244fd38b0c617ff827874d23d8e4e5231
Contents?: true
Size: 1.13 KB
Versions: 5
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require 'date' require 'fileutils' require 'json' module U3d # Internal class to use when trying to improve the prettifier # Opt-in with env variable U3D_REPORT_FAILURES class FailureReporter class << self def report(failure_type: "DEFAULT", failure_message: "", data: {}) return unless ENV['U3D_REPORT_FAILURES'] report = { type: failure_type, message: failure_message, data: data } FileUtils.mkdir_p default_report_path report_file = File.join( default_report_path, "#{failure_type}.#{Date.now.strftime('%Y%m%dT%H%M')}.failure.json" ) File.write(report_file, JSON.pretty_generate(report)) rescue StandardError => e UI.important "Unable to report a #{failure_type} failure. Please use --verbose to get more information about the failure" UI.verbose "Unable to report failure: #{e}" UI.verbose "Failure was: [#{failure_type}]: #{failure_message}" end def default_report_path File.join(U3dCore::Helper.data_path, 'failures') end end end end
Version data entries
5 entries across 5 versions & 1 rubygems