Skip to content

Commit 18425b8

Browse files
Add a generic base class for Active Storage exceptions
Closes #33292. [Andrei Makarov & George Claghorn]
1 parent 5f9f39e commit 18425b8

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

activestorage/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
* Active Storage error classes like `ActiveStorage::IntegrityError` and
2+
`ActiveStorage::UnrepresentableError` now inherit from `ActiveStorage::Error`
3+
instead of `StandardError`. This permits rescuing `ActiveStorage::Error` to
4+
handle all Active Storage errors.
5+
6+
*Andrei Makarov*, *George Claghorn*
7+
18
* Uploaded files assigned to a record are persisted to storage when the record
29
is saved instead of immediately.
310

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# frozen_string_literal: true
22

33
module ActiveStorage
4-
class InvariableError < StandardError; end
5-
class UnpreviewableError < StandardError; end
6-
class UnrepresentableError < StandardError; end
4+
# Generic base class for all Active Storage exceptions.
5+
class Error < StandardError; end
6+
7+
class InvariableError < Error; end
8+
class UnpreviewableError < Error; end
9+
class UnrepresentableError < Error; end
710

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

0 commit comments

Comments
 (0)