From dbda83e55b02946ff94b6c68c7093444318c6ef4 Mon Sep 17 00:00:00 2001 From: tworrall Date: Thu, 25 Mar 2021 16:50:08 -0400 Subject: [PATCH] improve BD error messaging --- .../blacklight_cornell_requests/request_controller.rb | 8 ++++++-- lib/blacklight_cornell_requests/version.rb | 2 +- release_notes.md | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/blacklight_cornell_requests/request_controller.rb b/app/controllers/blacklight_cornell_requests/request_controller.rb index 0e79417..5f1da5f 100755 --- a/app/controllers/blacklight_cornell_requests/request_controller.rb +++ b/app/controllers/blacklight_cornell_requests/request_controller.rb @@ -453,12 +453,16 @@ def make_bd_request req = BlacklightCornellRequests::CULBorrowDirect.new(requester, work, add_request) resp = req.request_from_bd(params) body_hash = JSON[resp.body] - if resp + if resp.is_a?(Net::HTTPSuccess) status = 'success' status_msg = I18n.t('requests.success') + " The Borrow Direct request number is #{body_hash['RequestNumber']}." else status = 'failure' - status_msg = "There was an error when submitting this request to Borrow Direct. Your request could not be completed." + if !body_hash['Problem'].nil? && body_hash['Problem']['Message'].present? + status_msg = body_hash['Problem']['Message'] + else + status_msg = "There was an error when submitting this request to Borrow Direct. Your request could not be completed." + end end end diff --git a/lib/blacklight_cornell_requests/version.rb b/lib/blacklight_cornell_requests/version.rb index a45fb8c..d64ef1b 100755 --- a/lib/blacklight_cornell_requests/version.rb +++ b/lib/blacklight_cornell_requests/version.rb @@ -1,3 +1,3 @@ module BlacklightCornellRequests - VERSION = "3.4.3" + VERSION = "3.4.4" end diff --git a/release_notes.md b/release_notes.md index 097b2fb..85dc365 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,8 @@ # Release Notes - blacklight-cornell-requests +## v3.4.4 +- Display the BD error message when possible to provide more context. (DISCOVERYACCESS-6967) + ## v3.4.3 - Use the new Borrow Direct 'Add Request' API. (DISCOVERYACCESS-6890)