@@ -217,8 +217,16 @@ def environment_flags_from_api
217217 environment_flags_from_document
218218 end
219219 else
220- rescue_with_default_handler do
221- return process_environment_flags_from_api
220+ begin
221+ process_environment_flags_from_api
222+ rescue StandardError
223+ if default_flag_handler
224+ return Flagsmith ::Flags ::Collection . new (
225+ { } ,
226+ default_flag_handler : default_flag_handler
227+ )
228+ end
229+ raise
222230 end
223231 end
224232 end
@@ -244,8 +252,16 @@ def get_identity_flags_from_api(identifier, traits = {})
244252 get_identity_flags_from_document ( identifier , traits )
245253 end
246254 else
247- rescue_with_default_handler do
248- return process_identity_flags_from_api ( identifier , traits )
255+ begin
256+ process_identity_flags_from_api ( identifier , traits )
257+ rescue StandardError
258+ if default_flag_handler
259+ return Flagsmith ::Flags ::Collection . new (
260+ { } ,
261+ default_flag_handler : default_flag_handler
262+ )
263+ end
264+ raise
249265 end
250266 end
251267 end
@@ -263,18 +279,6 @@ def process_identity_flags_from_api(identifier, traits = {})
263279 )
264280 end
265281
266- def rescue_with_default_handler
267- yield
268- rescue StandardError
269- if default_flag_handler
270- return Flagsmith ::Flags ::Collection . new (
271- { } ,
272- default_flag_handler : default_flag_handler
273- )
274- end
275- raise
276- end
277-
278282 def build_identity_model ( identifier , traits = { } )
279283 unless environment
280284 raise Flagsmith ::ClientError ,
0 commit comments