Skip to content

Commit

Permalink
remove unnecessary begins
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitch-A6 committed Sep 9, 2024
1 parent 2ed14b7 commit 3b37549
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions app/controllers/concerns/form_attachment_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,27 @@ def serializer_klass
end

def validate_file_upload_class!
begin
# is it either ActionDispatch::Http::UploadedFile or Rack::Test::UploadedFile
unless filtered_params[:file_data].class.name.include? 'UploadedFile'
raise Common::Exceptions::InvalidFieldValue.new('file_data', filtered_params[:file_data].class.name)
end
rescue => e
log_exception_to_sentry(e, { context: 'FAC_validate', class: filtered_params[:file_data].class.name })
raise e
# is it either ActionDispatch::Http::UploadedFile or Rack::Test::UploadedFile
unless filtered_params[:file_data].class.name.include? 'UploadedFile'
raise Common::Exceptions::InvalidFieldValue.new('file_data', filtered_params[:file_data].class.name)
end
rescue => e
log_exception_to_sentry(e, { context: 'FAC_validate', class: filtered_params[:file_data].class.name })
raise e
end

def save_attachment_to_cloud!
begin
form_attachment.set_file_data!(filtered_params[:file_data], filtered_params[:password])
rescue => e
log_exception_to_sentry(e, { context: 'FAC_cloud' })
raise e
end
form_attachment.set_file_data!(filtered_params[:file_data], filtered_params[:password])
rescue => e
log_exception_to_sentry(e, { context: 'FAC_cloud' })
raise e
end

def save_attachment_to_db!
begin
form_attachment.save!
rescue => e
log_exception_to_sentry(e, { context: 'FAC_db', errors: form_attachment.errors })
raise e
end
form_attachment.save!
rescue => e
log_exception_to_sentry(e, { context: 'FAC_db', errors: form_attachment.errors })
raise e
end

def form_attachment
Expand Down

0 comments on commit 3b37549

Please sign in to comment.