Skip to content

Commit

Permalink
Merge pull request #334 from ifad/feature/333-enhance-404
Browse files Browse the repository at this point in the history
Add status and description to 404 error
  • Loading branch information
tagliala authored Jan 17, 2025
2 parents 40f83ac + 6262fc0 commit 8dead74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit 8dead74

Please sign in to comment.