Skip to content

Commit a28c718

Browse files
committed
Backed out removing the #failure method.
1 parent 8acfc9b commit a28c718

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

app/controllers/concerns/idv/document_capture_concern.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,27 @@ def handle_stored_result(user: current_user, store_in_session: true)
1212
flash[:success] = t('doc_auth.headings.capture_complete')
1313
successful_response
1414
else
15-
FormResponse.new(
16-
{
17-
success: false,
18-
errors: error_hash(message),
19-
extra: { stored_result_present: stored_result.present? },
20-
},
21-
)
15+
extra = { stored_result_present: stored_result.present? }
16+
failure(nil, extra)
2217
end
2318
end
2419

2520
def successful_response
2621
FormResponse.new(success: true)
2722
end
2823

24+
# copied from Flow::Failure module
25+
def failure(message = nil, extra = nil)
26+
form_response_params = { success: false }
27+
form_response_params[:errors] = error_hash(message)
28+
form_response_params[:extra] = extra unless extra.nil?
29+
FormResponse.new(**form_response_params)
30+
end
31+
2932
def error_hash(message)
3033
{
3134
message: message || I18n.t('doc_auth.errors.general.network_error'),
32-
socure: stored_result&.errors[:socure],
35+
socure: stored_result&.errors&.dig(:socure),
3336
}
3437
end
3538

0 commit comments

Comments
 (0)