Skip to content


Add a generic base class for Active Storage exceptions
Browse files Browse the repository at this point in the history
Closes #33292.

[Andrei Makarov & George Claghorn]
  • Loading branch information
georgeclaghorn committed Aug 10, 2018
1 parent 5f9f39e commit 18425b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 7 additions & 0 deletions activestorage/
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
* Active Storage error classes like `ActiveStorage::IntegrityError` and
`ActiveStorage::UnrepresentableError` now inherit from `ActiveStorage::Error`
instead of `StandardError`. This permits rescuing `ActiveStorage::Error` to
handle all Active Storage errors.

*Andrei Makarov*, *George Claghorn*

* Uploaded files assigned to a record are persisted to storage when the record
is saved instead of immediately.

Expand Down
11 changes: 7 additions & 4 deletions activestorage/lib/active_storage/errors.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# frozen_string_literal: true

module ActiveStorage
class InvariableError < StandardError; end
class UnpreviewableError < StandardError; end
class UnrepresentableError < StandardError; end
# Generic base class for all Active Storage exceptions.
class Error < StandardError; end

class InvariableError < Error; end
class UnpreviewableError < Error; end
class UnrepresentableError < Error; end

# Raised when uploaded or downloaded data does not match a precomputed checksum.
# Indicates that a network error or a software bug caused data corruption.
class IntegrityError < StandardError; end
class IntegrityError < Error; end

0 comments on commit 18425b8

Please sign in to comment.