Skip to content

Commit 0d59aba

Browse files
committed
simplify exception handling inside method
1 parent 894ccba commit 0d59aba

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

lib/ldclient-rb/ldclient.rb

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,18 @@ def postfork(wait_for_sec = 5)
203203
private def get_plugin_hooks(environment_metadata)
204204
hooks = []
205205
@config.plugins.each do |plugin|
206-
begin
207-
hooks.concat(plugin.get_hooks(environment_metadata))
208-
rescue => e
206+
hooks.concat(plugin.get_hooks(environment_metadata))
207+
rescue => e
209208
@config.logger.error { "[LDClient] Error getting hooks from plugin #{plugin.metadata.name}: #{e}" }
210-
end
211209
end
212210
hooks
213211
end
214212

215213
private def register_plugins(environment_metadata)
216214
@config.plugins.each do |plugin|
217-
begin
218-
plugin.register(self, environment_metadata)
219-
rescue => e
220-
@config.logger.error { "[LDClient] Error registering plugin #{plugin.metadata.name}: #{e}" }
221-
end
215+
plugin.register(self, environment_metadata)
216+
rescue => e
217+
@config.logger.error { "[LDClient] Error registering plugin #{plugin.metadata.name}: #{e}" }
222218
end
223219
end
224220

@@ -425,12 +421,10 @@ def variation_detail(key, context, default)
425421
# @return [any]
426422
#
427423
private def try_execute_stage(method, hook_name)
428-
begin
429-
yield
430-
rescue => e
431-
@config.logger.error { "[LDClient] An error occurred in #{method} of the hook #{hook_name}: #{e}" }
432-
nil
433-
end
424+
yield
425+
rescue => e
426+
@config.logger.error { "[LDClient] An error occurred in #{method} of the hook #{hook_name}: #{e}" }
427+
nil
434428
end
435429

436430
#

0 commit comments

Comments
 (0)