improve Column not found error message

This commit is contained in:
simon lehericey 2024-10-11 11:23:36 +02:00
parent 3e73ff0d35
commit 4e0d3c2df1
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 8 additions and 2 deletions

View file

@ -38,6 +38,12 @@ class Column
end
def self.find(h_id)
Procedure.with_discarded.find(h_id[:procedure_id]).find_column(h_id:)
begin
procedure = Procedure.with_discarded.find(h_id[:procedure_id])
rescue ActiveRecord::RecordNotFound
raise ActiveRecord::RecordNotFound.new("Column: unable to find procedure #{h_id[:procedure_id]} from h_id #{h_id}")
end
procedure.find_column(h_id: h_id)
end
end

View file

@ -12,7 +12,7 @@ module ColumnsConcern
column = columns.find { _1.h_id == h_id } if h_id.present?
column = columns.find { _1.label == label } if label.present?
raise ActiveRecord::RecordNotFound if column.nil?
raise ActiveRecord::RecordNotFound.new("Column: unable to find h_id: #{h_id} or label: #{label} for procedure_id #{id}") if column.nil?
column
end