Skip to content

Allow Sentry.init without block argument#1235

Merged
st0012 merged 1 commit intogetsentry:masterfrom
sue445:sentry_init_without_block_arg
Jan 27, 2021
Merged

Allow Sentry.init without block argument#1235
st0012 merged 1 commit intogetsentry:masterfrom
sue445:sentry_init_without_block_arg

Conversation

@sue445
Copy link
Copy Markdown
Contributor

@sue445 sue445 commented Jan 25, 2021

Description

When SENTRY_DSN has been passed from environment variable, config.dsn in Sentry.init is needless.

But simply call Sentry.init will result in an error

e.g.

# example.rb
require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"
  gem "sentry-ruby", "4.1.4"
end

require "sentry-ruby"

Sentry.init
$ SENTRY_DSN=xxxxxx ruby example.rb

/Users/sue445/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sentry-ruby-4.1.4/lib/sentry-ruby.rb:67:in `init': no block given (yield) (LocalJumpError)
	from example.rb:10:in `<main>'

The workaround is below, but it's a bit dirty...

Sentry.init do
  # nop
end

# or

Sentry.init {  }

So I made it possible to call Sentry.init without block

Copy link
Copy Markdown
Contributor

@st0012 st0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change 👍

@st0012 st0012 merged commit 1f77277 into getsentry:master Jan 27, 2021
@sue445 sue445 deleted the sentry_init_without_block_arg branch January 27, 2021 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants