Open LSafer opened 1 year ago
It is way easier and more performant to depend on the MongoDB to perform the validation (like unique)
But it is not easy to catch those errors and re-throw them with custom messages
I am thinking of an Option to catch those errors and automatically handle them at the proper place using the error's pathname
Option
fun ObjectSchemaBuilder.foo() { // idk the actual exception name catch<MongoDBUniquenessInvalidationError> { error -> if (error.pathname == this.pathname) { rethrow(RuntimeError( "foo uniqueness wasn't met" )) } } }
It is way easier and more performant to depend on the MongoDB to perform the validation (like unique)
But it is not easy to catch those errors and re-throw them with custom messages
I am thinking of an
Option
to catch those errors and automatically handle them at the proper place using the error's pathname