improve Column not found error message
This commit is contained in:
parent
3e73ff0d35
commit
4e0d3c2df1
2 changed files with 8 additions and 2 deletions
|
@ -38,6 +38,12 @@ class Column
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.find(h_id)
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ module ColumnsConcern
|
||||||
column = columns.find { _1.h_id == h_id } if h_id.present?
|
column = columns.find { _1.h_id == h_id } if h_id.present?
|
||||||
column = columns.find { _1.label == label } if label.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
|
column
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue