Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lib/um_arclight/traject/ead2_component_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@
provide "component_identifier_format", "%<root_id>s_%<ref_id>s"
end

each_record do |_record, context|
next unless settings["repository"]
context.clipboard[:repository] = Arclight::Repository.find_by(
slug: settings["repository"]
).name
end

NAME_ELEMENTS = %w[corpname famname name persname].freeze

SEARCHABLE_NOTES_FIELDS = %w[
Expand Down
13 changes: 8 additions & 5 deletions lib/um_arclight/traject/ead2_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@
end

each_record do |_record, context|
next unless settings["repository"]

context.clipboard[:repository] = Arclight::Repository.find_by(
slug: settings["repository"]
).name
slug = settings["repository"]
raise "REPOSITORY_ID is not set; cannot index repository fields" if slug.blank?
repository = Arclight::Repository.find_by(slug: slug)
if repository.nil?
raise "No repository found for slug #{slug.inspect} — check REPOSITORY_ID " \
"against the slugs defined in config/repositories.yml"
Comment on lines +72 to +76

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could define a custom error type like TrajectEADIndexError and raise that specifically. What we're doing now will result in RuntimeErrors I think. E.g.

class TrajectEADIndexError < RuntimeError
end

# in your code
raise TrajectEADIndexError, "REPOSITORY_ID is not set..." if slug.blank?

end
context.clipboard[:repository] = repository.name
end

# ==================
Expand Down