{"record":{"id":"7e44ec1d2e1d99d4","repo":"ruby-concurrency/concurrent-ruby","slug":"unrecognized-error-mode","errorCode":null,"errorMessage":"unrecognized error mode","messagePattern":"unrecognized error mode","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/concurrent-ruby/concurrent/agent.rb","lineNumber":495,"sourceCode":"      # @param [Array<Concurrent::Agent>] agents the Agents on which to wait\n      # @return [Boolean] true if all actions complete before timeout\n      #\n      # @raise [Concurrent::TimeoutError] when timeout is reached\n      # @!macro agent_await_warning\n      def await_for!(timeout, *agents)\n        raise Concurrent::TimeoutError unless await_for(timeout, *agents)\n        true\n      end\n    end\n\n    private\n\n    def ns_initialize(initial, opts)\n      @error_mode    = opts[:error_mode]\n      @error_handler = opts[:error_handler]\n\n      if @error_mode && !ERROR_MODES.include?(@error_mode)\n        raise ArgumentError.new('unrecognized error mode')\n      elsif @error_mode.nil?\n        @error_mode = @error_handler ? :continue : :fail\n      end\n\n      @error_handler ||= DEFAULT_ERROR_HANDLER\n      @validator     = opts.fetch(:validator, DEFAULT_VALIDATOR)\n      @current       = Concurrent::AtomicReference.new(initial)\n      @error         = Concurrent::AtomicReference.new(nil)\n      @caller        = Concurrent::ThreadLocalVar.new(nil)\n      @queue         = []\n\n      self.observers = Collection::CopyOnNotifyObserverSet.new\n    end\n\n    def enqueue_action_job(action, args, executor)\n      raise ArgumentError.new('no action given') unless action\n      job = Job.new(action, args, executor, @caller.value || Thread.current.object_id)\n      synchronize { ns_enqueue_job(job) }","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/ruby-concurrency/concurrent-ruby/blob/0b88d5ff75f69b3740c8f0868e76f833cb2fd45d/lib/concurrent-ruby/concurrent/agent.rb#L477-L513","documentation":"Concurrent::Agent accepts an :error_mode option choosing failure behavior - :continue (keep processing subsequent actions after an error) or :fail (halt pending actions until restart) - validated against the frozen ERROR_MODES whitelist. Any other value raises ArgumentError at construction time.","triggerScenarios":"Concurrent::Agent.new(0, error_mode: :fail_fast), :continue_on_error, :raise, :ignore, or the string 'continue' (strings do not match the symbol whitelist).","commonSituations":"Guessing Clojure-flavored or custom names for the mode; reading the mode from config/ENV without symbolizing or validating; copying agent setup between projects or versions where expected option names differ.","solutions":["Use one of the two supported symbols: :continue or :fail.","Validate and default at the edge: raise on unknown config values at load time, symbolize strings with .to_sym once.","If you need default behavior, omit :error_mode entirely - it defaults to :continue when an :error_handler is given, else :fail."],"exampleFix":"# before\nagent = Concurrent::Agent.new(0, error_mode: :fail_fast)\n\n# after\nagent = Concurrent::Agent.new(0, error_mode: :fail)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"ERROR_MODES = %i[continue fail].freeze\n\ndef valid_error_mode?(mode)\n  ERROR_MODES.include?(mode)\nend\n\nmode = opts.fetch(:error_mode, :fail)\nraise ArgumentError, \"error_mode must be one of #{ERROR_MODES}\" unless valid_error_mode?(mode)\nagent = Concurrent::Agent.new(initial, error_mode: mode)","tryCatchPattern":"begin\n  agent = Concurrent::Agent.new(initial, **opts)\nrescue ArgumentError => e\n  raise ConfigError, \"bad agent options: #{e.message}\"\nend","preventionTips":["Only :continue and :fail exist - :continue keeps processing after action errors, :fail halts until restart.","Symbolize config strings once (.to_sym) and validate against a whitelist at load time.","Omit :error_mode to get the default (:continue with an :error_handler, else :fail)."],"tags":["ruby","concurrent-ruby","agent","argumenterror","options","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"0b88d5ff75f69b3740c8f0868e76f833cb2fd45d","analyzedAt":"2026-08-21T20:12:56.291Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}