Skip to content

Commit 2d44e5c

Browse files
committed
Report errors at once
1 parent 48bee57 commit 2d44e5c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

bin/import_mails

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ end.parse!(into: params)
1414

1515
list = List.find_by_name(params[:list])
1616

17+
errors = []
18+
1719
Message.transaction do
1820
(params[:from]..params[:to]).each do |seq|
1921
begin
@@ -29,7 +31,10 @@ Message.transaction do
2931
rescue ActiveRecord::RecordNotUnique
3032
STDERR.puts("#{list}:#{seq} already exists in Postgres")
3133
rescue StandardError => e
34+
errors << [seq, e]
3235
STDERR.puts("failed to import #{list}:#{seq}: #{e}")
3336
end
3437
end
3538
end
39+
40+
pp errors if errors.any?

0 commit comments

Comments
 (0)