Sha256: 3ade81955d4b24eecb2c488e68670cc8774e65bd4668e5659c1cdbaabcc50aab

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

module Sia
  # Sia-specific errors live here
  #
  # To catch any Sia error, just rescue `Sia::Error`.
  #
  #     begin
  #       # Code stuffs
  #     rescue Sia::Error
  #       # Handle the exceptiom
  #     end
  #
  class Error < StandardError

    # Raised when creating a safe with the incorrect password
    class PasswordError < Error; end

    # Raised when attempting to set bad configuration
    class ConfigurationError < Error; end

    # Raised when trying to set invalid option(s)
    class InvalidOptionError < ConfigurationError
      def initialize(invalids, available)
        msg = <<~MSG
          Got invalid option(s):
            #{invalids.map(&:inspect).join("\n  ")}
          Available options:
            #{available.map(&:inspect).join("\n  ")}
        MSG

        super(msg)
      end
    end

    # Raised with portable safes when trying to close a file not in the safe_dir
    class FileOutsideScopeError < Error; end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sia-0.1.0 lib/sia/error.rb