Skip to content

Commit

Permalink
Merge pull request #9 from NYPL-discovery/more-verbose-item-errors
Browse files Browse the repository at this point in the history
Add more descriptive errors, tests
  • Loading branch information
nonword authored Feb 1, 2019
2 parents 33274e7 + 50af59e commit 183602c
Show file tree
Hide file tree
Showing 15 changed files with 8,146 additions and 1,127 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
event.json
build/*
node_modules
.DS_Store
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ Note that `event.json` contains a sample API Gateway event that can, in theory,

A series of local test fixtures representing responses from the nypl data api, maintained in `./test/data/*.json`. These allow the test suite to run against a fixed set of data. If any fixtures need to be updated or added, a script is provided:

`node scripts/update-test-fixtures [--all|PATH] --envfile config/[environment].env --profile [aws profile]`
`./scripts/update-test-fixtures [--all|PATH] --envfile config/[environment].env --profile [aws profile]`

For example, to populate a test fixture for the api response for 'bibs/sierra-nypl/123':

`node scripts/update-test-fixtures bibs/sierra-nypl/123 --envfile config/[environment].env --profile [aws profile]`
`./scripts/update-test-fixtures bibs/sierra-nypl/123 --envfile config/[environment].env --profile [aws profile]`

To update ALL of the test fixtures:

`node scripts/update-test-fixtures --all --envfile config/[environment].env --profile [aws profile]`
`./scripts/update-test-fixtures --all --envfile config/[environment].env --profile [aws profile]`
2 changes: 1 addition & 1 deletion lib/data-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DataApi {
return bibIds
} else {
logger.error({'message': 'Error calling ' + url, response: resp})
return Promise.reject(new errors.NotFoundError('Barcode not found'))
return Promise.reject(new errors.NotFoundError('Barcode not found in ItemService'))
}
})
})
Expand Down
6 changes: 5 additions & 1 deletion lib/scsb-xml-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ function bibsAndItemsToScsbXml (bibs, items, customerCode = 'NA') {
if (itemCount === 0) {
logger.error({'message': 'Error generating SCSB XML', response: items})

throw new errors.NoItemsError('No items would be sent to ReCAP')
// It's possible all of the items passed in are not valid for export to recap
// There are several conditions that can cause this, including invalid location.
// Here's where they're checked:
// https://github.com/NYPL-discovery/convert-2-scsb-module/blob/3a891df24f5358c9403b074e60c81291fb1c3516/lib/parsemrc.js#L440-L505
throw new errors.NoItemsError('SCSB XML Formatter determined that no items were suitable for export to Recap')
}

if (scsbXml.length === 0) throw new errors.ScsbXmlGenerationError('Error parsing API into SCSB XML')
Expand Down
Loading

0 comments on commit 183602c

Please sign in to comment.