{"record":{"id":"0692081d337126e2","repo":"ruby-grape/grape","slug":"rescue-from-meta-selector-inspect-does-not-acce","errorCode":null,"errorMessage":"rescue_from #{meta_selector.inspect} does not accept additional arguments","messagePattern":"rescue_from #(.+?) does not accept additional arguments","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/grape/dsl/request_response.rb","lineNumber":100,"sourceCode":"\n      # @overload rescue_from(*exception_classes, **options)\n      #   @param [Array] exception_classes A list of classes that you want to rescue, or\n      #     one of the meta selectors +:all+, +:grape_exceptions+,\n      #     +:internal_grape_exceptions+. Meta selectors must be used alone;\n      #     mixing with exception classes raises +ArgumentError+.\n      #   @param [Block] block Execution block to handle the given exception.\n      #   @param [Proc] with Execution proc to handle the given exception as an alternative\n      #     to passing a block.\n      #   @param [Boolean] rescue_subclasses Also rescue subclasses of exception classes;\n      #     defaults to +true+.\n      #   @param [Boolean] backtrace Include the rescued exception's backtrace in the\n      #     rescue response body.\n      #   @param [Boolean] original_exception Include +inspect+ of the rescued exception\n      #     in the rescue response body.\n      def rescue_from(*args, with: nil, rescue_subclasses: true, backtrace: false, original_exception: false, &block)\n        handler = extract_handler(args, with:, block:)\n        meta_selector = (args & META_RESCUE_SELECTORS).first\n        raise ArgumentError, \"rescue_from #{meta_selector.inspect} does not accept additional arguments\" if meta_selector && args.size > 1\n\n        case meta_selector\n        when :all\n          inheritable_setting.add_all_rescue_handler(handler)\n        when :grape_exceptions\n          inheritable_setting.add_grape_exceptions_rescue_handler(handler)\n        when :internal_grape_exceptions\n          inheritable_setting.add_internal_grape_exceptions_rescue_handler(handler)\n        else\n          inheritable_setting.add_rescue_handlers(args.to_h { |klass| [klass, handler] }, subclasses: rescue_subclasses)\n        end\n\n        inheritable_setting.add_rescue_options(RescueOptions.new(backtrace:, original_exception:))\n      end\n\n      # Allows you to specify a default representation entity for a\n      # class. This allows you to map your models to their respective\n      # entities once and then simply call `present` with the model.","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/ruby-grape/grape/blob/22d7975629846a3c0c7bd2b34e140a7a1b4af8f6/lib/grape/dsl/request_response.rb#L82-L118","documentation":"`rescue_from` accepts special meta-selectors (:all, :grape_exceptions, :internal_grape_exceptions) that configure a whole class of handlers, plus regular exception classes. A meta-selector configures a distinct handler set, so mixing it with exception classes in the same call (`rescue_from :all, CustomError`) is ambiguous and raises ArgumentError at boot.","triggerScenarios":"`rescue_from :all, ArgumentError do |e| ... end`. `rescue_from :grape_exceptions, NotFoundError, with: :render`. Any call where one positional arg is a meta-selector symbol and args.size > 1.","commonSituations":"Gradually tightening error handling by adding specific classes next to an existing `rescue_from :all`. Copy-pasting a rescue_from line and appending another class. Using :grape_exceptions for the structured error format while also wanting domain errors in one call.","solutions":["Split into separate calls: one for the meta-selector, one for the exception classes.","Order them deliberately - specific `rescue_from SomeError` handlers and `rescue_from :all` can coexist as distinct registrations."],"exampleFix":"# before\nrescue_from :all, ArgumentError do |e| ... end # raises\n\n# after\nrescue_from ArgumentError do |e| ... end\nrescue_from :all do |e| ... end","handlingStrategy":"validation","validationCode":"META_SELECTORS = %i[all grape_exceptions internal_grape_exceptions].freeze\n\ndef assert_single_rescue_from_arg(*args)\n  meta = args & META_SELECTORS\n  raise ArgumentError, \"#{meta.first.inspect} must be alone\" if meta.any? && args.size > 1\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One concern per rescue_from call: either one meta-selector or exception classes, never both.","Write specific `rescue_from Klass` before a catch-all `rescue_from :all`.","Mount the API in a boot spec so argument errors in rescue_from fail immediately."],"tags":["grape","rescue-from","error-handling","dsl"],"backgroundTag":"rescue-from-invalid-arguments","analyzedSha":"22d7975629846a3c0c7bd2b34e140a7a1b4af8f6","analyzedAt":"2026-08-21T17:03:54.627Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}