Sha256: c684a8412b7d13cdf71e9b3b9a9e12c11965a0c1aad0f6df6a7f38a1105c2abd

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

module Munge
  module Errors
    class Base < StandardError
    end

    module ErrorWithIdentifier
      def initialize(identifier)
        @identifier = identifier
      end
    end

    class DoubleWriteError < Base
      include ErrorWithIdentifier

      def message
        "attempted to write #{@identifier} twice"
      end
    end

    class DuplicateItemError < Base
      include ErrorWithIdentifier

      def message
        "item with id `#{@identifier}` already exists"
      end
    end

    class ItemNotFoundError < Base
      include ErrorWithIdentifier

      def message
        "item not found (#{@identifier})"
      end
    end

    class ItemHasNoRouteError < Base
      include ErrorWithIdentifier

      def message
        "item `#{@identifier}` has no route"
      end
    end

    class DuplicateTransformerError < Base
      include ErrorWithIdentifier

      def message
        "already registered transformer `#{@identifier}`"
      end
    end

    class TransformerNotFoundError < Base
      include ErrorWithIdentifier

      def message
        "transformer `#{@identifier}` is not installed"
      end
    end

    class InvalidRouterError < Base
      include ErrorWithIdentifier

      def message
        "invalid router with type #{@identifier}"
      end
    end

    class ConfigYmlNotFound < Base
      include ErrorWithIdentifier

      def message
        "Expected to find config file: #{@identifier}\n" \
        "Are you in the correct directory, or did you run `munge init`?"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
munge-0.14.0 lib/munge/errors.rb
munge-0.13.0 lib/munge/errors.rb