Skip to content

Commit

Permalink
Allow disabling of error handling
Browse files Browse the repository at this point in the history
Per issue #528
Allow opting out of catching errors in the application controller.
Allows usage of web_console, better_errors, and other solutions.
  • Loading branch information
wheeyls committed Jan 28, 2024
1 parent 60d5542 commit b8a2be5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/lookbook/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def raise_not_found(message = "Page not found")
end

def handle_error(err)
raise err if Lookbook.config.preview_disable_error_handling

@error = err.is_a?(Lookbook::Error) ? err : Lookbook::Error.new(original: err)
@status_code = get_status_code(err)

Expand Down
1 change: 1 addition & 0 deletions config/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ shared:
preview_disable_action_view_annotations: true
preview_type_default: view_component
preview_sort_scenarios: false
preview_disable_error_handling: false

page_collection_label: "Pages"
page_nav_filter: false
Expand Down
4 changes: 4 additions & 0 deletions lib/lookbook/stores/config_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def highlighter_options=(options = nil)
store[:highlighter_options].merge!(options.to_h)
end

def preview_disable_error_handling=(value)
store[:preview_disable_error_handling] = value
end

def ui_theme=(name)
name = name.to_s
if Theme.valid_theme?(name)
Expand Down

0 comments on commit b8a2be5

Please sign in to comment.