app/channels/stimulus_reflex/channel.rb in stimulus_reflex-3.5.0.pre8 vs app/channels/stimulus_reflex/channel.rb in stimulus_reflex-3.5.0.pre9

- old
+ new

@@ -25,10 +25,29 @@ if reflex reflex.rescue_with_handler(exception) reflex.logger&.error error_message reflex.error data: data, body: "#{exception} #{exception.backtrace.first.split(":in ")[0] if Rails.env.development?}" else - StimulusReflex.config.logger.error error_message + if exception.is_a? StimulusReflex::Reflex::VersionMismatchError + mismatch = "Reflex failed due to stimulus_reflex gem/NPM package version mismatch. Package versions must match exactly.\nNote that if you are using pre-release builds, gems use the \"x.y.z.preN\" version format, while NPM packages use \"x.y.z-preN\".\n\nstimulus_reflex gem: #{StimulusReflex::VERSION}\nstimulus_reflex NPM: #{data["version"]}" + + StimulusReflex.config.logger.error("\n\e[31m#{mismatch}\e[0m") unless StimulusReflex.config.on_failed_sanity_checks == :ignore + + if Rails.env.development? + CableReady::Channels.instance[stream_name].console_log( + message: mismatch, + level: "error", + reflex_id: data["reflexId"] + ).broadcast + end + + if StimulusReflex.config.on_failed_sanity_checks == :exit + sleep 0.1 + exit! + end + else + StimulusReflex.config.logger.error error_message + end if body.to_s.include? "No route matches" initializer_path = Rails.root.join("config", "initializers", "stimulus_reflex.rb") StimulusReflex.config.logger.warn <<~NOTE