Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

[ORM] A way to customize mongodb exceptions #4

Description

@LSafer

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

fun ObjectSchemaBuilder.foo() {
  // idk the actual exception name
   catch<MongoDBUniquenessInvalidationError> { error ->
      if (error.pathname == this.pathname) {
          rethrow(RuntimeError( "foo uniqueness wasn't met" ))
      }
   }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions