Sha256: b9f9433a8db9efa2de3753d80cb51e0c370a4ab2f642789af709dc690711d10f

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 KB

Contents

# encoding: UTF-8

require "forwardable"

module Spontaneous
  class Error < StandardError; end

  class UnknownTypeException < Error
    def initialize(parent, type)
      super("Unknown content type '#{type}' requested in class #{parent}")
    end
  end

  class UnknownStyleException < Error
    def initialize(style_name, klass)
      super("Unknown style '#{style_name}' for class #{klass}")
    end
  end

  # raised when trying to show something that is not showable due to
  # ancestor being hidden
  class NotShowable < Error
    def initialize(content, hidden_ancestor_id)
      @content, @hidden_ancestor_id = content, hidden_ancestor_id
    end
  end

  class UnknownLayoutError < Error
    def initialize(parent_class, layout_name)
      @parent_class, @layout_name = parent_class, layout_name
    end
  end


  class UnknownOutputException < Error
    def initialize(content_class, unsupported_output_name)
      super("Type '#{content_class}' does not output '#{unsupported_output_name}'")
    end
  end

  class UnsupportedFormatException < Error
    def initialize(style, unsupported_format)
      super("'#{unsupported_format}' format not supported by style '#{style.name}'.\nTemplate path: #{style.directory}\n")
    end
  end

  class InvalidPrototypeDefinitionError < Error; end

  class AnonymousRootException < Error
    def initialize
      super("Content roots must have a valid slug")
    end
  end

  class SchemaModificationError < Error
    extend Forwardable

    attr_reader :modification

    def initialize(modification)
      @modification = modification
    end

    def_delegators :@modification, :added_classes, :removed_classes
    def_delegators :@modification, :added_fields,  :removed_fields
    def_delegators :@modification, :added_boxes,   :removed_boxes
    def_delegators :@modification, :added_styles,  :removed_styles
    def_delegators :@modification, :added_layouts, :removed_layouts
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta5 lib/spontaneous/errors.rb
spontaneous-0.2.0.beta4 lib/spontaneous/errors.rb
spontaneous-0.2.0.beta3 lib/spontaneous/errors.rb
spontaneous-0.2.0.beta2 lib/spontaneous/errors.rb