app/controllers/lookbook/previews_controller.rb in lookbook-0.7.1 vs app/controllers/lookbook/previews_controller.rb in lookbook-0.7.2.beta.0
- old
+ new
@@ -1,25 +1,22 @@
module Lookbook
class PreviewsController < ApplicationController
- EXCEPTIONS = [
- ViewComponent::PreviewTemplateError,
- ViewComponent::ComponentError,
- ViewComponent::TemplateError,
- ActionView::Template::Error
- ]
-
def self.controller_path
"lookbook/previews"
end
before_action :lookup_entities, only: [:preview, :show]
before_action :set_title
def preview
if @example
set_params
- render html: render_examples(examples_data)
+ begin
+ render html: render_examples(examples_data)
+ rescue => exception
+ render_in_layout "lookbook/error", layout: "lookbook/basic", error: exception, disable_header: true
+ end
else
render_in_layout "not_found"
end
end
@@ -28,12 +25,12 @@
begin
set_params
@examples = examples_data
@drawer_panels = drawer_panels.filter { |name, panel| panel[:show] }
@preview_panels = preview_panels.filter { |name, panel| panel[:show] }
- rescue *EXCEPTIONS
- render_in_layout "error"
+ rescue => exception
+ render_in_layout "lookbook/error", error: exception
end
else
render_in_layout "not_found"
end
end
@@ -150,10 +147,10 @@
controller.request = request
controller.response = response
@preview_controller ||= controller
end
- def render_in_layout(path)
- render "not_found", layout: params[:lookbook_embed] ? "lookbook/basic" : "lookbook/application"
+ def render_in_layout(path, layout: nil, **locals)
+ render path, layout: layout.presence || (params[:lookbook_embed] ? "lookbook/basic" : "lookbook/application"), locals: locals
end
end
end