app/controllers/lookbook/application_controller.rb in lookbook-1.2.1 vs app/controllers/lookbook/application_controller.rb in lookbook-1.3.0
- old
+ new
@@ -1,10 +1,8 @@
module Lookbook
class ApplicationController < ActionController::Base
- if respond_to?(:content_security_policy)
- content_security_policy false, if: -> { Rails.env.development? }
- end
+ content_security_policy(false) if respond_to?(:content_security_policy)
protect_from_forgery with: :exception
helper Lookbook::ApplicationHelper
helper Lookbook::OutputHelper
@@ -42,8 +40,20 @@
end
def render_in_layout(path, layout: nil, **locals)
@error = locals[:error]
render path, layout: layout.presence || (params[:lookbook_embed] ? "lookbook/basic" : "lookbook/application"), locals: locals
+ end
+
+ def prettify_error(exception)
+ error_params = {}
+ if exception.is_a?(ViewComponent::PreviewTemplateError)
+ error_params = {
+ file_path: @preview&.full_path,
+ line_number: 0,
+ source_code: @target&.source
+ }
+ end
+ Lookbook::Error.new(exception, **error_params)
end
end
end