Sha256: f6f6a94e67e4d685f360b5a1ccfa2faeec3118c2811530a6ee94a49b3761ed13

Contents?: true

Size: 955 Bytes

Versions: 5

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

module ENVV
  class Error < ::StandardError; end

  class InvalidSchemaError < Error
    def initialize
      super("A ::Dry::Schema::Params is expected. See https://github.com/16/envv#schema.")
    end
  end

  class InvalidEnvError < Error
    def initialize
      super("ENV or an an enumerable is expected.")
    end
  end

  class ValidationError < Error
    ERROR_MESSAGE_TITLE = "Environment variables validation failed:"

    attr_reader :error_messages

    def initialize(error_messages)
      @error_messages = error_messages
      super(full_error_message.join("\n"))
    end

    private

    def full_error_message
      messages = [ERROR_MESSAGE_TITLE]
      messages.concat(@error_messages.map { |v| "\t* #{v}" })
      messages << " "
    end
  end

  class NotBuilt < Error
    def initialize
      super("Undefined registry. You must build ENVV first. See https://github.com/16/envv. ")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
envv-0.2.1 lib/envv/errors.rb
envv-0.2.0 lib/envv/errors.rb
envv-0.1.2 lib/envv/errors.rb
envv-0.1.1 lib/envv/errors.rb
envv-0.1.0 lib/envv/errors.rb