Skip to content

Commit

Permalink
Use feature detection to find out if detailed_message is available
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Sep 13, 2023
1 parent 10be5db commit efaf97b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/roda/plugins/exception_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def exception_page_js
private
if RUBY_VERSION >= '3.2'
if Exception.method_defined?(:detailed_message)
def exception_page_exception_message(exception)
exception.detailed_message(highlight: false).to_s
end
Expand Down
2 changes: 1 addition & 1 deletion spec/plugin/exception_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def req(path = '/', headers={})
end
end

message = RUBY_VERSION >= '3.2' ? "foo (RuntimeError)" : "foo"
message = Exception.method_defined?(:detailed_message) ? "foo (RuntimeError)" : "foo"

it "returns HTML page with exception information if text/html is accepted" do
ep_app
Expand Down

0 comments on commit efaf97b

Please sign in to comment.