Sha256: 6682f84cadb134e52ad3d56080d24bd37e75f40bc6389352adc6126c45e69fef
Contents?: true
Size: 928 Bytes
Versions: 2
Compression:
Stored size: 928 Bytes
Contents
module Voom module Commands module ExtractErrors def extract_fk_errors(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 def extract_errors(e) return e.form_errors if e.respond_to?(:form_errors) && e.form_errors.any? {exception: e.message} end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
voom-commands-0.1.1 | lib/voom/commands/extract_errors.rb |
voom-commands-0.1.0 | lib/voom/commands/extract_errors.rb |