Sha256: 64e87ba116e99d88986b4e49c91a180a3e6b113ce6feca3afb42ad7bbfdce707

Contents?: true

Size: 832 Bytes

Versions: 2

Compression:

Stored size: 832 Bytes

Contents

class ErrorReporter < Controller
	self.define do
		on error(
			Configuration::S3NoSuchKeyError,
			Configuration::NoSuchFileError
		)	do |error|
			write_error 404, error
		end

		on error MemoryLimit::MemoryLimitedExceededError do |error|
			write_error 413, error
		end

		on error Configuration::Thumbnail::ThumbnailingError do |error|
			status = defined?(error.remote_error.status) ? error.remote_error.status : 500
			write_error status, error
		end

		on error Configuration::ZeroBodyLengthError do |error|
			write_error 400, error
		end

		on error Configuration::SourceFailoverAllFailedError do |error|
			if [Configuration::S3NoSuchKeyError, Configuration::NoSuchFileError].member? error.errors.first.class
				write_error 404, error
			else
				write_error 500, error
			end
		end

		run DefaultErrorReporter
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
httpimagestore-1.8.0 lib/httpimagestore/error_reporter.rb
httpimagestore-1.7.0 lib/httpimagestore/error_reporter.rb