Skip to content

Commit

Permalink
Add some basic error handling for unloadable Holdings
Browse files Browse the repository at this point in the history
  • Loading branch information
xhero committed Jun 20, 2018
1 parent 0b5adfb commit 141b33f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/admin/holding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ def edit
@show_history = true if params[:show_history]
@editor_profile = EditorConfiguration.get_show_layout @item
@page_title = format_holding(@item)

# Force marc to load
begin
@item.marc.load_source(true)
rescue ActiveRecord::RecordNotFound
flash[:error] = I18n.t(:unloadable_record)
AdminNotifications.notify("Holding #{@item.id} seems unloadable, please check", @item).deliver_now
redirect_to admin_holding_path @item
return
end

end

def destroy
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ def holding

@item = Holding.find( params[:object_id] )

@item.marc.load_source(true)
begin
@item.marc.load_source(true)
rescue ActiveRecord::RecordNotFound
puts "Could not properly load MarcHolding #{@item.id}"
end

@editor_profile = EditorConfiguration.get_show_layout @item

render :template => 'marc_show/show_preview', :locals => { :opac => opac }
Expand Down

0 comments on commit 141b33f

Please sign in to comment.