4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/voom/commands/extract_errors.rb', line 4
def (e)
errmsg = e.message
table, _foreign_key, foreign_table = e.message.match(/PG::ForeignKeyViolation: ERROR:.*\"(.*)\".*\"(.*)\"[\n].*\"(.*)\"/)&.captures
if table && _foreign_key && foreign_table
errmsg = "Unable to delete or update #{table.singularize.humanize.titleize}. "\
"It is referred to from one or more #{foreign_table.humanize.titleize}. "\
"You will need to update or remove any #{foreign_table.humanize.titleize} that refer to this "\
"#{table.singularize.humanize.titleize} first."
end
{exception: errmsg}
end
|