hyper63 / hyper63/hyper-adapter-couchdb

Map CouchDB errors to HyperErrs

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
enhancement errors
Dominant language
JavaScript
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

I'd consider this more of an enhancement.

A "HyperErr" is a simple object of the shape:

```
{
ok: false,
status: 404, // optional
msg: 'not found' // optional
}
```

It happens that most CouchDB responses follow this shape, and so mapping is unnecessary most of the time, and we already do mapping on some apis ie. `retrieveDocument` maps `404`, `createDocument` maps/handles `409`, `400` and `403`, etc.

But I do think this adapter could do a better job of explicitly mapping per request statuses to specific HyperErrs instead of just accepting whatever is sent back from CouchDB. This way, the mapping can be tested.

This issue is meant to track that enhancement of the non-happy path. This includes:

- [ ] `createDatabase` - should return a HyperErr if the database already exists
- [ ] `removeDatabase` - should return a HyperErr if no database is found to remove
- [ ] `removeDocument` - should return a HyperErr if no document is found to remove

These above have commented out tests that can be used to verify we've implemented the expectation. But there are lots of errors that could be returned from Couch

Ideally, the solution is something that is reusable to handle all sorts of CouchDB errors, similar to the approach for [mapping errors in the elasticsearch adapter](https://github.com/hyper63/hyper-adapter-elasticsearch/blob/dcf177fa761d99cf9ffd3b0ea9ce2e9f028ac537/utils.js#LL66C6-L66C6)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.