Skip to content

Commit

Permalink
Merge pull request #338 from sul-dlss/use_better_http_status_331
Browse files Browse the repository at this point in the history
Return 500 error instead of 400 when request is OK but underlying data is bad
  • Loading branch information
jcoyne committed Aug 26, 2019
2 parents 8c46604 + 3205916 commit f017360
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ObjectsController < ApplicationController
end

rescue_from(DublinCoreService::CrosswalkError) do |e|
render status: 400, plain: e.message
render status: 500, plain: e.message
end

# Register new objects in DOR
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/objects_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
context 'with bad metadata' do
let(:error_message) { "DublinCoreService#ng_xml produced incorrect xml (no children):\n<xml/>" }

it 'returns a 400 error' do
it 'returns a 500 error' do
allow(PublishMetadataService).to receive(:publish).and_raise(DublinCoreService::CrosswalkError, error_message)
post :publish, params: { id: item.pid }
expect(response.status).to eq(400)
expect(response.status).to eq(500)
expect(response.body).to eq(error_message)
end
end
Expand Down

0 comments on commit f017360

Please sign in to comment.