aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib/active_storage/errors.rb
diff options
context:
space:
mode:
authorCameron Bothner <cameronbothner@gmail.com>2018-08-18 13:31:33 -0400
committerCameron Bothner <cameronbothner@gmail.com>2018-08-21 15:31:14 -0400
commit5cd2d07bdcda4b2f547830d2becafe5e0722fa43 (patch)
tree78cd529618c2032f1f9049ae2b1c052eaaf23800 /activestorage/lib/active_storage/errors.rb
parent87d5415f0aa3e6f9f74f645a47370dd854375a1a (diff)
downloadrails-5cd2d07bdcda4b2f547830d2becafe5e0722fa43.tar.gz
rails-5cd2d07bdcda4b2f547830d2becafe5e0722fa43.tar.bz2
rails-5cd2d07bdcda4b2f547830d2becafe5e0722fa43.zip
Translate service-specific missing object exceptions into a generic one
`ActiveStorage::Blob#download` and `ActiveStorage::Blob#open` raise `ActiveStorage::FileNotFoundError` when the corresponding file is missing from the storage service. Services translate service-specific missing object exceptions (e.g. `Google::Cloud::NotFoundError` for the GCS service and `Errno::ENOENT` for the disk service) into `ActiveStorage::FileNotFoundError`.
Diffstat (limited to 'activestorage/lib/active_storage/errors.rb')
-rw-r--r--activestorage/lib/active_storage/errors.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activestorage/lib/active_storage/errors.rb b/activestorage/lib/active_storage/errors.rb
index f4bf66a615..6475c1d076 100644
--- a/activestorage/lib/active_storage/errors.rb
+++ b/activestorage/lib/active_storage/errors.rb
@@ -19,4 +19,8 @@ module ActiveStorage
# 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 < Error; end
+
+ # Raised when ActiveStorage::Blob#download is called on a blob where the
+ # backing file is no longer present in its service.
+ class FileNotFoundError < Error; end
end