Skip to content

Commit efaa214

Browse files
committed
New signature convention for exceptions
1 parent 4cf0ddf commit efaa214

File tree

5 files changed

+9
-20
lines changed

5 files changed

+9
-20
lines changed

lib/zeitwerk/cref.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@ def set(value)
5757
@mod.const_set(@cname, value)
5858
end
5959

60-
# @raise [NameError]
61-
#: () -> top
60+
#: () -> top ! NameError
6261
def get
6362
@mod.const_get(@cname, false)
6463
end
6564

66-
# @raise [NameError]
67-
#: () -> void
65+
#: () -> void ! NameError
6866
def remove
6967
@mod.__send__(:remove_const, @cname)
7068
end

lib/zeitwerk/loader.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ def unload
229229
# This method is not thread-safe, please see how this can be achieved by
230230
# client code in the README of the project.
231231
#
232-
# @raise [Zeitwerk::Error]
233-
#: () -> void
232+
#: () -> void ! Zeitwerk::Error
234233
def reload
235234
raise ReloadingDisabledError unless reloading_enabled?
236235
raise SetupRequired unless @setup

lib/zeitwerk/loader/callbacks.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ module Zeitwerk::Loader::Callbacks # :nodoc: all
55

66
# Invoked from our decorated Kernel#require when a managed file is autoloaded.
77
#
8-
# @raise [Zeitwerk::NameError]
9-
#: (String) -> void
8+
#: (String) -> void ! Zeitwerk::NameError
109
internal def on_file_autoloaded(file)
1110
cref = autoloads.delete(file)
1211

lib/zeitwerk/loader/config.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ def initialize
105105
# the same process already manages that directory or one of its ascendants or
106106
# descendants.
107107
#
108-
# @raise [Zeitwerk::Error]
109-
#: (String | Pathname, namespace: Module) -> void
108+
#: (String | Pathname, namespace: Module) -> void ! Zeitwerk::Error
110109
def push_dir(path, namespace: Object)
111110
unless namespace.is_a?(Module) # Note that Class < Module.
112111
raise Zeitwerk::Error, "#{namespace.inspect} is not a class or module object, should be"
@@ -171,8 +170,7 @@ def dirs(namespaces: false, ignored: false)
171170
# You need to call this method before setup in order to be able to reload.
172171
# There is no way to undo this, either you want to reload or you don't.
173172
#
174-
# @raise [Zeitwerk::Error]
175-
#: () -> void
173+
#: () -> void ! Zeitwerk::Error
176174
def enable_reloading
177175
mutex.synchronize do
178176
break if @reloading_enabled
@@ -245,9 +243,7 @@ def on_setup(&block)
245243
# # ...
246244
# end
247245
#
248-
# @raise [TypeError]
249-
#: (String) { (top, String) -> void } -> void
250-
#| (:ANY) { (String, top, String) -> void } -> void
246+
#: (String?) { (top, String) -> void } -> void ! TypeError
251247
def on_load(cpath = :ANY, &block)
252248
raise TypeError, "on_load only accepts strings" unless cpath.is_a?(String) || cpath == :ANY
253249

@@ -270,9 +266,7 @@ def on_load(cpath = :ANY, &block)
270266
# # ...
271267
# end
272268
#
273-
# @raise [TypeError]
274-
#: (String) { (top, String) -> void } -> void
275-
#| (:ANY) { (String, top, String) -> void } -> void
269+
#: (String?) { (top, String) -> void } -> void ! TypeError
276270
def on_unload(cpath = :ANY, &block)
277271
raise TypeError, "on_unload only accepts strings" unless cpath.is_a?(String) || cpath == :ANY
278272

lib/zeitwerk/loader/helpers.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ module Zeitwerk::Loader::Helpers
103103
CNAME_VALIDATOR = Module.new #: Module
104104
private_constant :CNAME_VALIDATOR
105105

106-
# @raise [Zeitwerk::NameError]
107-
#: (String, String) -> Symbol
106+
#: (String, String) -> Symbol ! Zeitwerk::NameError
108107
private def cname_for(basename, abspath)
109108
cname = inflector.camelize(basename, abspath)
110109

0 commit comments

Comments
 (0)