Skip to content

Make Warning.process(/foo/) { :raise } fail on initial call #17

@splattael

Description

@splattael

Problem

I was wondering if Warning.process(/foo/) { :raise } is explicitly supported as it works only if no prior calls to Warning.process has been made.

Consider this code:

require 'warning'

Warning.process(/foo/) { :raise } # This works?
Warning.process(/bar/) { :raise }
# => ArgumentError (comparison of Regexp with Regexp failed)

The first argument of Warning.process must be a path and actions can be passed as a Hash:

require 'warning'

Warning.process('', /foo/ => :raise)
Warning.process('', /bar/ => :raise)
warn("foo") # => RuntimeError (foo)
warn("bar") # => RuntimeError (bar)

Proposed solution

Make Warning.process(/foo/) { :raise } always fail.

Happy to create a PR if the proposed solution is accepted 💪

Refs

Refs https://gitlab.com/gitlab-org/gitlab/-/merge_requests/91789

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions