Sha256: 893ce7bec911ea7741b63fc8d5de80246d34e081c7aa8b2404c17886034d2f08
Contents?: true
Size: 781 Bytes
Versions: 10
Compression:
Stored size: 781 Bytes
Contents
class Error < ActiveRecord::Base self.inheritance_column = nil # <-- Error has a column named 'type' validates :sha, :message, :backtrace, presence: true def self.find_or_create_for_exception(exception) message = exception.message backtrace = exception.backtrace.join("\n") sha = Digest::SHA1.hexdigest([message, backtrace].join) error = create_with( type: exception.class.name, message: message, backtrace: backtrace ).find_or_create_by(sha: sha) # TODO: we'll move this to `create_with` and incorporate it into the SHA; # but for now we'll try to collect types for errors error.update_column :type, exception.class.name unless error.type error rescue ActiveRecord::RecordNotUnique find_by(sha: sha) end end
Version data entries
10 entries across 10 versions & 1 rubygems