lib/nanoc/base/entities/site.rb in nanoc-4.11.2 vs lib/nanoc/base/entities/site.rb in nanoc-4.11.3
- old
+ new
@@ -2,10 +2,17 @@
module Nanoc
module Int
# @api private
class Site
+ # Error that is raised when multiple items or layouts with the same identifier exist.
+ class DuplicateIdentifierError < ::Nanoc::Error
+ def initialize(identifier, type)
+ super("There are multiple #{type}s with the #{identifier} identifier.")
+ end
+ end
+
include Nanoc::Core::ContractsSupport
attr_reader :code_snippets
attr_reader :config
attr_accessor :data_source
@@ -50,10 +57,10 @@
contract C::IterOf[C::Or[Nanoc::Core::Item, Nanoc::Core::Layout]], String => self
def ensure_identifier_uniqueness(objects, type)
seen = Set.new
objects.each do |obj|
if seen.include?(obj.identifier)
- raise Nanoc::Int::Errors::DuplicateIdentifier.new(obj.identifier, type)
+ raise DuplicateIdentifierError.new(obj.identifier, type)
end
seen << obj.identifier
end
self