Skip to content

Commit

Permalink
Polish a few details before release
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Nov 5, 2022
1 parent 9e4e06a commit 8898781
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

* Controlled errors in a couple of situations:

- Attempting to eager load or reload before invoking `setup` now raises
`Zeitwerk::SetupRequired`.
- Attempting to eager load or reload without previously invoking `setup` now
raises `Zeitwerk::SetupRequired`.

- The method `Zeitwerk::Loader#push_dir` raises `Zeitwerk::Error` if it gets
an anonymous custom namespace.

These should be backwards compatible, because they raise in circumstances that
didn't work anyway.
didn't work anyway. The goal here is to raise a meaningful error upfront.

* Enforcement of private interfaces continues with another gradual patch.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ loader.reload

There is no way to undo this, either you want to reload or you don't.

Enabling reloading after setup raises `Zeitwerk::Error`. Attempting to reload without having it enabled raises `Zeitwerk::ReloadingDisabledError`. Attempting to reload before calling `setup` raises `Zeitwerk::SetupRequired`.
Enabling reloading after setup raises `Zeitwerk::Error`. Attempting to reload without having it enabled raises `Zeitwerk::ReloadingDisabledError`. Attempting to reload without previously calling `setup` raises `Zeitwerk::SetupRequired`.

Generally speaking, reloading is useful while developing running services like web applications. Gems that implement regular libraries, so to speak, or services running in testing or production environments, won't normally have a use case for reloading. If reloading is not enabled, Zeitwerk is able to use less memory.

Expand Down
8 changes: 4 additions & 4 deletions lib/zeitwerk/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def setup
# @sig () -> void
def unload
mutex.synchronize do
raise Zeitwerk::SetupRequired unless @setup
raise SetupRequired unless @setup

# We are going to keep track of the files that were required by our
# autoloads to later remove them from $LOADED_FEATURES, thus making them
Expand Down Expand Up @@ -218,7 +218,7 @@ def unload
# @sig () -> void
def reload
raise ReloadingDisabledError unless reloading_enabled?
raise Zeitwerk::SetupRequired unless @setup
raise SetupRequired unless @setup

unload
recompute_ignored_paths
Expand Down Expand Up @@ -294,7 +294,7 @@ def eager_load_all
Registry.loaders.each do |loader|
begin
loader.eager_load
rescue Zeitwerk::SetupRequired
rescue SetupRequired
# This is fine, we eager load what can be eager loaded.
end
end
Expand All @@ -308,7 +308,7 @@ def eager_load_namespace(mod)
Registry.loaders.each do |loader|
begin
loader.eager_load_namespace(mod)
rescue Zeitwerk::SetupRequired
rescue SetupRequired
# This is fine, we eager load what can be eager loaded.
end
end
Expand Down

0 comments on commit 8898781

Please sign in to comment.