Sha256: 1f4bd3c14adba825246b3e3108abd01154c48ca6a153ad7357ed5d10ebb62f6d

Contents?: true

Size: 1.99 KB

Versions: 21

Compression:

Stored size: 1.99 KB

Contents

# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


require "google/cloud/errors"

module Google
  module Cloud
    module Storage
      ##
      # # FileVerificationError
      #
      # Raised when a File download fails the verification.
      class FileVerificationError < Google::Cloud::Error
        ##
        # The type of digest that failed verification,
        # :md5 or :crc32c.
        attr_accessor :type

        ##
        # The value of the digest on the google-cloud file.
        attr_accessor :gcloud_digest

        ##
        # The value of the digest on the downloaded file.
        attr_accessor :local_digest

        # @private
        def self.for_md5 gcloud_digest, local_digest
          new("The downloaded file failed MD5 verification.").tap do |e|
            e.type = :md5
            e.gcloud_digest = gcloud_digest
            e.local_digest = local_digest
          end
        end

        # @private
        def self.for_crc32c gcloud_digest, local_digest
          new("The downloaded file failed CRC32c verification.").tap do |e|
            e.type = :crc32c
            e.gcloud_digest = gcloud_digest
            e.local_digest = local_digest
          end
        end
      end

      ##
      # # SignedUrlUnavailable Error
      #
      # This is raised when File#signed_url is unable to generate a URL due to
      # missing credentials needed to create the URL.
      class SignedUrlUnavailable < Google::Cloud::Error
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
google-cloud-storage-0.20.0 lib/google/cloud/storage/errors.rb