Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add status and description to 404 error #334

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class App < Sinatra::Base
# A custom 404 page
#
not_found do
JSON.dump(error: 'not found')
JSON.dump(error: 'not found', status: 404, description: 'Document not found')
end

#
Expand Down
4 changes: 3 additions & 1 deletion spec/lib/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def show_backtrace(response)
}
expect(last_response.status).to eq 404
expect(last_response.content_type).to eq 'application/json'
expect(JSON.parse(last_response.body)).to be_a Hash
expect(JSON.parse(last_response.body)).to match(
{ "status" => 404, "description" => "Document not found", "error" => "not found" }
)
expect(Colore::Sidekiq::ConversionWorker).not_to have_received(:perform_async)
end
end
Expand Down
Loading