Skip to content

Commit

Permalink
Return 500 error instead of 400 when request is OK but underlying dat…
Browse files Browse the repository at this point in the history
…a is bad

Fixes #331
  • Loading branch information
mjgiarlo committed Aug 26, 2019
1 parent 8c46604 commit 3205916
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 3205916

Please sign in to comment.