Skip to content
This repository was archived by the owner on Dec 5, 2022. It is now read-only.

Database exception middleware pattern #122

Open
sbgreene1307 opened this issue Sep 29, 2017 · 3 comments
Open

Database exception middleware pattern #122

sbgreene1307 opened this issue Sep 29, 2017 · 3 comments

Comments

@sbgreene1307
Copy link

The current setup for db commands seems tightly coupled to the HystrixBadRequestException.

This forces me to write an ignore-function that will propagate exceptions I care about and then an exception-wrapper function to process database errors. For example, if an insert fails on a table with a duplicate key error, then I propagate this by matching the message pattern, setting the HystrixBadRequestException message to something useful for me, and finally catching this exception in my wrapping function just to get the message. This requires new developers to know to use the wrap-sql-exception function.

As an alternative, friboo.system/db.clj, could implement the middleware pattern as explained in this article.

This would allow me to write wrapper functions for the exceptions as I see fit and other devs won't need to worry about remembering to wrap their sql cmds.

@dazld
Copy link

dazld commented Oct 13, 2017

thanks for the proposal! would you like to take a crack at a PR showing an example?

@sbgreene1307
Copy link
Author

sbgreene1307 commented Nov 11, 2017

@dazld An example with the current pattern I have to follow?

@dazld
Copy link

dazld commented Nov 13, 2017

no, I think I've understood your current pain. I'd be interested in what your solution would look like.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants